Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

{[b]section[/b] name='' loop=''}

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
rschlege
Smarty n00b


Joined: 21 Apr 2003
Posts: 2

PostPosted: Mon Apr 21, 2003 2:49 pm    Post subject: {[b]section[/b] name='' loop=''} Reply with quote

I'd like to generate a two-dimensional table. Therfore it would be useful to do something with the modulo-operator (%) like this:

<table><tr>
{section name=items_id loop=$items}
<td>
This is {$items[items_id]}
</td>
{if $items_id%5 == 0}
</tr>
<tr>
{/if}

{/section}
</tr></table>

Can someone show me how it is be done the easiest way?

Roman
Back to top
View user's profile Send private message
rschlege
Smarty n00b


Joined: 21 Apr 2003
Posts: 2

PostPosted: Mon Apr 21, 2003 3:19 pm    Post subject: two-dimensional table Reply with quote

Sorry for the rash question... it was easier than I expected:

<table><tr>
{section name=items_id loop=$items}
<td>
This is {$items[items_id]}
</td>
{if $smarty.section.items_id.index%5 == 0}
</tr>
<tr>
{/if}
{/section}
</table>

Greez
Roman
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Apr 21, 2003 8:06 pm    Post subject: Reply with quote

Or, use the intuitive Smarty syntax Smile

{if $smarty.section.foo.index is div by 5}
...
{/if}
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP