|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
emergetw Smarty n00b
Joined: 17 Jul 2003 Posts: 2
|
Posted: Thu Jul 17, 2003 7:21 pm Post subject: display 5 names and drop to a new line |
|
|
{$i = 0}
{section name=rat loop=$names}
{$names[rat]},
{$i = $i + 1}
{if $i eq 5}
{$i = 0}
<br>
{else}
{/if}
{/section}
how would i do something like that?
After it loops through 5 names i want it to drop to a new line.
names are assigned as smarty->assign('names',array('bob','jim','joe','steve','sally','kate','sarah')) |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Jul 17, 2003 7:27 pm Post subject: |
|
|
Read the {section} documentation, there are all kinds of special variables you can access such as section loop indexes (0,1,2...) and iterations (1,2,3...)
example:
Code: | {section name="foo" loop=$bar}
{if $smarty.section.foo.iteration eq 5}
{* do something here on 5th iteration*}
{/if}
{if $smarty.section.foo.iteration is div by 5}
{* do this _every_ 5th iteration *}
{/if}
{/section}
|
|
|
Back to top |
|
emergetw Smarty n00b
Joined: 17 Jul 2003 Posts: 2
|
Posted: Thu Jul 17, 2003 7:42 pm Post subject: |
|
|
thanks very much. it works. i am new to smarty and didnt realize that the other things listed in a section were other aspects of the function (ie. iteration under section), i just thought they were other suggested functions to look at.
Anyways thanks for the help. |
|
Back to top |
|
|
|
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
|