Re: loop counting

Michael Greenish <[email protected]> Thu, 3 May 2007 11:18:37 -0700 (PDT)
Newsgroups gmane.comp.lang.perl.modules.html-template
Message-ID <[email protected]>
Thanks, Mathew, for the response.  That looks easy enough.  Now, what if I have two nested tmpl_loops and I want to only apply the break tag on the first set of nested template loop date?  

For example:

<tmpl_loop albums>
 
<tmpl_loop pictures>
    ...
    <img src="<tmpl_var src>" alt="" />
   <tmpl_if expr="(__counter__ % 3) == 0 && PARENT_LOOP_COUNTER < 1"><br /></tmpl_if>

</tmpl_loop>
</tmpl_loop>

Can I "see" the counter for the parent loop inside the child loop?

Thanks.

greanie

----- Original Message ----
From: Mathew Robertson <[email protected]>
To: Michael Greenish <[email protected]>
Cc: [email protected]
Sent: Monday, April 30, 2007 7:31:07 PM
Subject: Re: [htmltmpl] loop counting




  
  

sure thing - but it does require using H::T::Expr. 
I use the following snippet as-is to a gallery of photo's.  Notice the
use of modulo (%).



Mathew




<table width=100% border=0 cellpadding=1 cellspacing=1>
        <TMPL_LOOP gallery>
                <TMPL_IF EXPR="(__counter__ % 3) == 1">
                        <tr valign=top>
                </TMPL_IF>
                        <td width=33% align=center valign=top class=text>
                                <a href="<TMPL_VAR paths.gallery>/<TMPL_VAR NAME=filename ESCAPE=URL>" title="Click to enlarge"><img alt="" src="<TMPL_VAR paths.thumbnail>/<TMPL_VAR NAME=filename ESCAPE=URL>" width=180 height=200 border=0></a><br>
                                <<TMPL_VAR spacer> width=10 height=6><br>
                                <TMPL_VAR NAME=description ESCAPE=TEXT>
                        </td>
                <TMPL_IF EXPR="(__counter__ % 3) == 0">
                        </tr>
                        <tr>
                                <td colspan=3>
                                        <<TMPL_VAR spacer> height=18 width=100%>
                                </td>
                        </tr>
                </TMPL_IF>
        </TMPL_LOOP>
</table>






Michael Greenish wrote:

  Hello,

I have a series of images that I would like to output but I want to limit it to only 4 images per row.  I would like to put a br tag to force the 5th, 9th, etc... image to go to the next row.  Can I do this completely int the template using an iterator or resettable counter?

Thanks,

greanie



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Html-template-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/html-template-users
  






__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

_______________________________________________
Html-template-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/html-template-users