Smarty templates - printing array contents using modulus ..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
richardl
Forum Newbie
Posts: 1
Joined: Sun Aug 12, 2007 8:55 pm

Smarty templates - printing array contents using modulus ..

Post by richardl »

Hi all,

I am literally this one thing away from finishing a program I am making, and am frustratingly stuck on what should be very simple. I have an array of varying length, and I would like it to print out 10 items from the array first, and then have a <br /> tag, and start the next 10, <br />, next 10, etc ..

I found this code online:

Code: Select all

[code]{section name=i loop=$items} 
<Print out one item>
{if $oTmp.section.i.iteration % 9 == 1}
<print br tag>
{/if}
{/section}[/code]
However, I had tried to use this code for my program and it doesnt seem to be working. The smarty template call is being made in a PHP file with this command:

$oTmp->assign(array(

And in that array one of the items is the array I am looping through. I can loop through the array in the HTML page just fine, the items display normally but it is still only printing them all on one line. Can anyone see whats wrong with my code and why the modulus code I have added isn't working? Any and all suggestions welcome.

Thanks!
Post Reply