|
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 |
stratoz4 Smarty Rookie
Joined: 12 Aug 2003 Posts: 6
|
Posted: Fri Sep 12, 2003 3:57 pm Post subject: limit loop count |
|
|
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 |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Fri Sep 12, 2003 4:07 pm Post subject: |
|
|
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 |
|
stratoz4 Smarty Rookie
Joined: 12 Aug 2003 Posts: 6
|
Posted: Sat Sep 13, 2003 1:51 am Post subject: |
|
|
i saw something with an if statement once, thats why i asked. |
|
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
|