Posted By

crypticsoft on 03/10/11


Tagged

Smarty columns tpl


Versions (?)

Smarty Template : Multiple Column Loop


 / Published in: Smarty
 

Take array and create multiple columns, define divisible by value ($divis) from total results then use modulus within the loop. This example shows multiple columns for unordered list items.

  1. <div class="bullet-text">
  2. {{assign var="cnt" value=$results|@count }}
  3.  
  4. {{ math equation="cnt/3" cnt=$results|@count assign=divis }}
  5. Total Count: {{$cnt}}
  6. Divided by 3: {{$divis}}
  7.  
  8.  
  9. <ul class="col">
  10. {{section name=i loop=$results}}
  11. <li>
  12. <strong><a href="/search/{{$results[i]|urlencode}}">{{$results[i]|validate}}</a></strong>
  13. </li>
  14. {{if $smarty.section.i.iteration % $divis == 0}}
  15. </ul><ul class="col">
  16. {{/if}}
  17. {{/section}}
  18. </ul>
  19.  
  20. </div>

Report this snippet  

You need to login to post a comment.