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

Help me with {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 -> General
View previous topic :: View next topic  
Author Message
IceJOKER
Smarty n00b


Joined: 08 Jul 2014
Posts: 2

PostPosted: Tue Jul 08, 2014 2:42 pm    Post subject: Help me with {section} Reply with quote

$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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Tue Jul 08, 2014 8:28 pm    Post subject: Reply with quote

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
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