|
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: Tue Aug 12, 2003 7:15 am Post subject: Help with loop |
|
|
Hi look below at this code, i have hi-lited a foreach loop..
see how its foreach.. i want it to display the top 5 instead of all, how would i do that?
_________________________________________________
<table class="outer" cellspacing="1">
<th class="head">Forum</th>
<th class="head"><{$block.lang_topic}></th>
<th class="head" align="center"><{$block.lang_replies}></th>
<th class="head" align="center"><{$block.lang_views}></th>
<th class="head" align="right"><{$block.lang_lastpost}></th>
</tr>
<{foreach item=topic from=$block.topics}>
<tr>
<td class="even" onmouseout='this.className="even";' onmouseover='this.className="neven";' valign='middle' align="center"><a href="<{$xoops_url}>/modules/pbboard/viewforum.php?f=<{$topic.forum_id}>&sid=<{$topic.sess_id}>"><{$topic.forum_name}></a></td>
<td class="odd" onmouseout='this.className="odd";' onmouseover='this.className="neven"; this.style.cursor="hand";' onclick='window.location.href="<{$xoops_url}>/modules/pbboard/viewtopic.php?t=<{$topic.id}>&sid=<{$topic.sess_id}>"'>
<div align=center><a href="<{$xoops_url}>/modules/pbboard/viewtopic.php?t=<{$topic.id}>&sid=<{$topic.sess_id}>"><{$topic.title}></a> <{$topic.pages}></div></td>
<td class="even" onmouseout='this.className="even";' onmouseover='this.className="neven";' align="center"><{$topic.replies}></td>
<td class="odd" onmouseout='this.className="odd";' onmouseover='this.className="neven";' align="center"><{$topic.views}></td>
<td class="even" onmouseout='this.className="even";' onmouseover='this.className="neven";' align="right"><{$topic.time}><br><{$block.lang_by}>:&<{$topic.last_post_name}></td>
</tr>
<{/foreach}>
<tr>
<td class="foot" align="right" colspan="5"><a href="<{$xoops_url}>/modules/pbboard/"><{$block.lang_visitforums}></a></td>
</table> |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Aug 12, 2003 9:37 am Post subject: |
|
|
2 possibilities:
- do this before in php: assign a blocks-top-five-array and loop over this.
- or
{foreach item=topic name=topics from=$block.topics}
{if $smarty.foreach.topics.iteration <= 5}
// print one of the top5 here
{/if}
{/foreach} |
|
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
|