Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
iterating through a list
Paul
I am iterating through a list and dumping the results into a table. After each entry I am putting in a horizontal line by inserting a table row with a bgcolor of grey and a height of 1
What I don't want to do or even need to do is have that cell after the LAST item in the table. Is there a fancy piece of iw code that knows when you've reached the end of the iteration? Any ideas?
Find more posts tagged with
Comments
akshathp
One crude way...
In iteration, check for the value to exist. You could use an "if" statement in between to check and only if the value exists, print it.
Hope this helps!
Akshat Pramod Sharma
Interwoven Inc.
Paul
What I am seeing is that when I do this it ALWAYS returns true because the field was JUST displayed and it hasn't "moved on" to the next item... What do you mean by "in between?
akshathp
Could you please post your code in this post? By "in between" I meant to use <iw_if> within <iw_iterate> tags.
Thanks!
Akshat Pramod Sharma
Interwoven Inc.
Paul
Relationship Managers
]]>
<tr><td BGCOLOR="#ffffff" WIDTH="25"><p CLASS="smallblue"><IMG src=/images/pshim.gif></p></td>
<td BGCOLOR="#ffffff" VALIGN="Top" COLSPAN="2"WIDTH="550"><p CLASS="smallblue"><IMG src=/images/pshim.gif></p></td></tr>
<tr><td BGCOLOR="#cccccc" WIDTH="25"><p CLASS="smallblue"><IMG src=/images/pshim.gif></p></td>
<td BGCOLOR="#cccccc" VALIGN="Top" COLSPAN="2"WIDTH="550"><p CLASS="smallblue"><IMG src=/images/pshim.gif></p></td></tr>
</td></tr>
</table>
Paul
<table BORDER="0" BORDERCOLOR="green" CELLSPACING="2" CELLPADDING="0" WIDTH="549">
<tr><td COLSPAN="3" BGCOLOR="#999999"><img src="/images/pshim.gif" ALT=" " WIDTH="1" HEIGHT="1" BORDER="0"></td></tr>
<tr><td VALIGN="top" COLSPAN="3"><p CLASS="smallblue">Relationship Managers</p></td></tr>
<tr><td COLSPAN="3" BGCOLOR="#999999"><img src="/images/pshim.gif" ALT=" " WIDTH="1" HEIGHT="1" BORDER="0"></td></tr>
]]>
<iw_iterate list='dcr.Relationship Managers' var='relman'>
<iw_iterate list='relman.RM' var='rms'>
<td WIDTH="25"><p CLASS="smallblue"><img src="/images/pshim.gif" ALT=" " WIDTH="25" HEIGHT="1" BORDER="0"></p></td>
<td VALIGN=top WIDTH="226"><p CLASS="small"><iw_value name='rms.Area'/></p></td>
<td>
<table border="0" Cellpadding="0" Cellspacing="0">
<iw_iterate list='rms.Manager_Name' var='man'>
<td VALIGN=TOP WIDTH="300"><p CLASS="small"><iw_value name='man.Name'/></p></td></tr>
</iw_iterate>
</table></td></tr>
<iw_if expn=' {iw_value name="rms.Area"/} eq ""'>
<iw_then>
<![CDATA[
<tr><td BGCOLOR="#ffffff" WIDTH="25"><p CLASS="smallblue"><img src="/images/pshim.gif" ALT=" " WIDTH="25" HEIGHT="1" BORDER="0"></p></td>
<td BGCOLOR="#ffffff" VALIGN="Top" COLSPAN="2"WIDTH="550"><p CLASS="smallblue"><img src="/images/pshim.gif" ALT=" " WIDTH="1" HEIGHT="1" BORDER="0"></p></td></tr>
]]>
</iw_then>
<iw_else>
<![CDATA[
<tr><td BGCOLOR="#cccccc" WIDTH="25"><p CLASS="smallblue"><img src="/images/pshim.gif" ALT=" " WIDTH="25" HEIGHT="1" BORDER="0"></p></td>
<td BGCOLOR="#cccccc" VALIGN="Top" COLSPAN="2"WIDTH="550"><p CLASS="smallblue"><img src="/images/pshim.gif" ALT=" " WIDTH="1" HEIGHT="1" BORDER="0"></p></td></tr>
]]>
</iw_else>
</iw_if>
</iw_iterate>
</iw_iterate>
<![CDATA[
</td></tr>
</table>
akshathp
1. How about you first fetch the count of replicants that user has created by running the iw_iterate and fetching values in a PERL variable. And then in the main iterate, with iw_if tag check for the count value. This way, you could display blank cell till (n-1) counts. I know this is crude but untill you get a better solution, this could serve the purpose. Otherwise the iterate will always be true.
2. I noticed that the HTMl constructs that you are using would need <tr> tags at one odd places which are missing. Ofcourse this has nothing to do with the current requirement that you have. I just noticed and thought of bringing to your attention so that the page format for sensitive browsers doesn't go bad.
Hope this helps!
Akshat Pramod Sharma
Interwoven Inc.
Paul
So what you're suggesting would be to do an iterate to get the count BEFORE doing the iterate that gets the values?
akshathp
Yes. I know this is a crude way to get the count. Not sure if there are already any functions existing with the perl modules for Templating. But if you can't find any function then you could use this method as an immediate solution.
You could run one iterate ony to fetch the count and have an if condition in the second iterate which will be your iterate to display values where this if condition will check if the tempcounter has reached to maincount, then not display that blank cell.
Hope this helps!
Akshat Pramod Sharma
Interwoven Inc.
ProfessorX
I was wondering this to...thanks
The Professor-
laj1
since you say you want to emit the horizontal line on every iteration but the last, you should employ the little known "iteration" attribute of the iw_iterate tag, and then use a little algorithmic have waving. I'll write pseudocode below, actual implementation is left as an exercise for the reader. NOTE: my indentation is squished by the forum software. When I wrote this it was beautifully indented.
<iw_iterate list="yourrepliacant" var="myvar" iteration="i" >
<iw_if expn={iw_value name="i" /} gt 1>
<!-- only output the line if there is more than one iteration -->
<output the code for the line >
</iw_if>
<output your replicant data>
</iw_iterate>
By checking the iteration before outputing the replicant values, we ensure that the first replicant the last thing we ever output in the loop is replicant values, and that we never output the line on the first replicant.
I sure wish there was a simple, out-of-the-box method for getting the number of replicants before iterating.
Len.
Len Jaffe
My Heart Is A Flower
AmyRush
Another way that I have accomplished a similar result is to move the horizontal line to the beginning of the loop. So you are writing the line at the top of the content rather than the bottom... set a "flag" outside of the loop to indicate the first pass, use that to suppress the horizontal line on the first pass. At the end of the loop, change the value of the flag so that the line is printed on all the remaining passes.
Just a thought.