|
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 |
IceJOKER Smarty n00b
Joined: 08 Jul 2014 Posts: 2
|
Posted: Tue Jul 08, 2014 2:42 pm Post subject: Help me with {section} |
|
|
$items = range(0, 27);
$count = count($items);
$pages = ceil($count/5);
for($i = 0, $k=1; $i <= $pages; $i++){
echo '<ul>';
for($j = 1; $j <= 5; $j++, $k++){
if(!isset($items[$k])) break 2;
echo '<li>'.$items[$k].'</li>';
}
echo '</ul>';
}
How can i to write the code on smarty style?
i can't to understand smarty {section}
p.s. sorry for my english |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Jul 08, 2014 8:28 pm Post subject: |
|
|
Better use {foreach}
In Smarty 3
Code: |
<ul>
{foreach $items as $item}
{if $item@index is div by 5}<ul>{/if}
<li>{$item}</li>
{if $item@iteration is div by 5}</ul>{/if}
{/foreach}
{if $item@total is not div by 5}</ul>{/if}
|
See http://www.smarty.net/docs/en/language.function.foreach.tpl |
|
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
|