Gossamer Forum
Quote Reply
Links Loop
I want to use links loop to to use 2 different link-display-styles which alternate

What would be the syntax of link loop?

<%loop links_loop%>
<%if first%> ........

and then?

Thank you
Michael




--
Michael Skaide

http://www.cycle24.de

Quote Reply
Re: [Michael Skaide] Links Loop In reply to
this is used in the webmail templates...

<td bgcolor="<%if even%>white<%else%>grey<%endif%>" nowrap>

give that a try?

cheers,
R.

Last edited by:

ryel01: Dec 14, 2001, 1:06 PM
Quote Reply
Re: [Michael Skaide] Links Loop In reply to
from the GT::Template docs (which has some examples of many other functions)



Quote:
<%row_num%> - a counter for what row is being looped, starts at 1.
<%first%> - boolean that is true if this is the first row, false otherwise.
<%last%> - boolean that is true if this is the last row, false otherwise.
<%inner%> - boolean that is true if this is not first and not last.
<%even%> - boolean is true if row_num is even.
<%odd%> - boolean is true if row_num is odd.

Booleans are on/off values 0/1. So, you'd be able to use them simply as:

<%if last%> or <%ifnot last%>

<%row_num%> is a "counter" which will have the current record number on each iteration through the loop, if you wanted to do something fancy, or control column breaks, or similar. If the loop variable returned 17 records, row_num will increment from 1 to 17 each iteration.

this would be something you'd use if you wanted more than 2 columns, since odd/even would be simpler to use as built in functions.

By using <%first%> and <%last%> ie: <%if first%>, etc, you can open and close tables _cleanly_ inside the loop, rather than outside. There are many reasons to do this, especially if the logic is more complicated than a simple print.




PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.