I
I
IceJOKER2014-07-08 16:48:19
Smarty
IceJOKER, 2014-07-08 16:48:19

How to properly implement a smarty section loop?

There are variables:
$items //an array with data (for example, let there be values ​​from 0 to 55)
you need to run through this array and display the data in this form:

<ul>
  <li>1</li>
  <li>2</li>
  <li>3</li>
  <li>4</li>
  <li>5</li>
</ul>
<ul>
  <li>6</li>
  <li>7</li>
  <li>8</li>
  <li>9</li>
  <li>10</li>
</ul>

.......
I can’t figure out the {section} smarty
in php, I froze something like this
<?php

$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>';
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question