Hello

There is an iteration over the elements:

<ul> {foreach from=$item.confessions.items item=confession} <li>{$confession.content}</li> {/foreach} </ul> 

How can you tell when half of the li elements are derived? In half, you will need to close the ul tag and open a new one with the other half li

thank

  • And why did you need to "tear" the list in half? - tutankhamun

2 answers 2

Like that

 <ul> {foreach from=$item.confessions.items item=confession name=confession} <li>{$confession.content}</li> {if $smarty.foreach.confession.index == floor($smarty.foreach.confession.total / 2) } </ul><ul> {/if} {/foreach} </ul> 

You can also try the condition (smarty2 is not at hand, I can not check)

 $smarty.foreach.confession.index == $smarty.foreach.confession.total >> 1 

In smarty3 it would be like this:

 <ul> {foreach $item.confessions.items as $confession} <li>{$confession.content}</li> {if $confession@index == $confession@total >> 1} </ul><ul> {/if} {/foreach} </ul> 
  • Eh, in Smarty I felt boots I will try to figure it out - Nikita Shchypylov
  • @ Nikita Schipilov Forgot to write. In {foreach} you need to add name=confession . Completed the answer - tutankhamun
  • Thanks for the answer!) I hope I’m not going to work with Smarti anymore) - Nikita Shchypylov

 ul { -moz-column-count: 2; column-count: 2; padding: 0; list-style-position: inside; } 
 <ul> <li>Не надо :) <li>Не надо :) <li>Не надо :) <li>Не надо :) <li>Не надо :) <li>Не надо :) <li>Не надо :) <li>Не надо :) <li>Не надо :) <li>Не надо :) <li>Не надо :) <li>Не надо :) <li>Не надо :) <li>Не надо :) <li>Не надо :) <li>Не надо :) <li>Не надо :) <li>Не надо :) <li>Не надо :) <li>Не надо :) </ul> 

  • Think ahead? :) - smellyshovel
  • That's exactly why I asked why I need to tear the list :) - tutankhamun