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

about the section

 
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 -> Tips and Tricks
View previous topic :: View next topic  
Author Message
rex1982
Smarty Rookie


Joined: 24 Oct 2005
Posts: 28

PostPosted: Sat Nov 12, 2005 3:26 pm    Post subject: about the section Reply with quote

<table border='1' cellspacing='0' cellpadding='0' align='center' width='300'>
<tr>
{section name=user2 loop=$img}
{ if $smarty.section.user2.rownum % 3 == 0}
<td align='center'><img src='{$img[user2].0}'></td>
{else}
</tr>
<tr>
<td align='center'><img src='{$img[user2].0}'></td>
{/if}
{/section}
</tr>
</table>

i wanna output three records per row

how i do it......

Thx...
Back to top
View user's profile Send private message
kills
Smarty Elite


Joined: 28 May 2004
Posts: 493

PostPosted: Sun Nov 13, 2005 11:49 am    Post subject: Reply with quote

In my opinion you should prepare your array with the structure and use 2 loops...

Pseudocode:

[php:1:b182732921]
Array(
0 => Array(
0=> Array( *Record1*)
1=> Array( *Record2*)
2=> Array( *Record3*)
)
1 => Array(
0=> Array( *Record4*)
1=> Array( *Record5*)
2=> Array( *Record6*)
)
2 => Array(
0=> Array( *Record7*)
1=> Array( *Record8*)
2=> Array( *Record9*)
)
)
[/php:1:b182732921]

Template:
[php:1:b182732921]
{foreach name=outer item=row from=$result}
{foreach item=col from=$row}
{$col}<br />
{/foreach}
{/foreach}
[/php:1:b182732921]

Bye,
Markus
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Sun Nov 13, 2005 4:09 pm    Post subject: Reply with quote

the FAQ in the wiki has examples of multi-column/row output. also see {html_table}
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 -> Tips and Tricks 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