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

limit loop count

 
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 -> General
View previous topic :: View next topic  
Author Message
stratoz4
Smarty Rookie


Joined: 12 Aug 2003
Posts: 6

PostPosted: Fri Sep 12, 2003 3:57 pm    Post subject: limit loop count Reply with quote

hi in this one below it outputs all records, i only want it to do 5.. how would i modify this to do so:
--------------------------------------------------------------------------------

<table class="outer" cellspacing="1">

<{if $block.full_view == true}>
<tr>
<th><{$block.lang_forum}></th>
<th><{$block.lang_topic}></th>
<th align="center"><{$block.lang_replies}></th>
<th align="center"><{$block.lang_views}></th>
<th align="right"><{$block.lang_lastpost}></th>
</tr>

<{foreach item=topic from=$block.topics}>
<tr class="<{cycle values="even,odd"}>">
<td><a href="<{$xoops_url}>/modules/newbb/viewforum.php?forum=<{$topic.forum_id}>"><{$topic.forum_name}></a></td>
<td><a href="<{$xoops_url}>/modules/newbb/viewtopic.php?topic_id=<{$topic.id}>&forum=<{$topic.forum_id}>"><{$topic.title}></a></td>
<td align="center"><{$topic.replies}></td>
<td align="center"><{$topic.views}></td>
<td align="right"><{$topic.time}></td>
</tr>
<{/foreach}>

<{else}>

<tr>
<td class="head"><{$block.lang_topic}></td>
<td class="head" align="center"><{$block.lang_replies}></td>
<td class="head" align="right"><{$block.lang_lastpost}></td>
</tr>

<{foreach item=topic from=$block.topics}>
<tr class="<{cycle values="even,odd"}>">
<td><a href="<{$xoops_url}>/modules/newbb/viewtopic.php?topic_id=<{$topic.id}>&forum=<{$topic.forum_id}>"><{$topic.title}></a></td>
<td align="center"><{$topic.replies}></td>
<td align="right"><{$topic.time}></td>
</tr>
<{/foreach}>

<{/if}>

</table>

<div style="text-align:right; padding: 5px;">
<a href="<{$xoops_url}>/modules/newbb/"><{$block.lang_visitforums}></a>
</div>
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Fri Sep 12, 2003 4:07 pm    Post subject: Reply with quote

either limit the assigned array to 5 rows in your PHP code (if you are using a db, try limiting rows in the select). Otherwise, switch from a {foreach} to {section} which allows you to control thr # of iterations perfromed.
Back to top
View user's profile Send private message
stratoz4
Smarty Rookie


Joined: 12 Aug 2003
Posts: 6

PostPosted: Sat Sep 13, 2003 1:51 am    Post subject: Reply with quote

i saw something with an if statement once, thats why i asked.
Back to top
View user's profile Send private message
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 -> General 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