I need to create the following ul after the creation of 5 li , and ul to continue to create li in ul . Only ul should be all on the same level. Here is the code, CMS OpenCart.
<?php foreach (array_chunk($category['children'], ceil(count($category['children']) / $category['column'])) as $children) { ?> <div class="children clearfix"> <ul class="children-list children-list-col clearfix"> <?php $k=0; foreach ($children as $child) {(($k%5==0) ? "</ul><ul>" :"");?> <li> <a class="link" href="<?php echo $child['href']; ?>" > <img class="thumb" src="<?php echo $child['thumb']?>" width="40" height="40" alt="" /> <span class="text"><?php echo $child['name']; ?></span></a> </li> <?php } ?> </ul> </div> <?php } ?> Perhaps there is another solution, thanks in advance!
UPD: With this code, it gives an error which is written in the header.
<?php foreach ($children as $child) {(($k%5==0) ? echo "</ul><ul>" : echo"");?> UPD: On some basis, the code <?php $k=0; foreach ($children as $child) { if($k%5==0) { echo "</ul><ul>"; } $k++;?> <?php $k=0; foreach ($children as $child) { if($k%5==0) { echo "</ul><ul>"; } $k++;?> <?php $k=0; foreach ($children as $child) { if($k%5==0) { echo "</ul><ul>"; } $k++;?> , which shows signs of efficiency, thanks tCode , does not quite work as I need .. I have been suffering with this for 2 days already, of course, because of not knowing ..
<div class="children clearfix"> <ul class="children-list children-list-col clearfix"> </ul><ul> <li> <a class="link" href="http://rumishop2/component/cmp23" > <img class="thumb" src="http://rumishop2/image/cache/no_image-100x100.png" width="40" height="40" alt="" /> <span class="text">Components</span></a> </li> <li> <a class="link" href="http://rumishop2/component/PC123" > <img class="thumb" src="http://rumishop2/image/cache/no_image-100x100.png" width="40" height="40" alt="" /> <span class="text">PC</span></a> </li> <li> <a class="link" href="http://rumishop2/component/mouse" > <img class="thumb" src="http://rumishop2/image/cache/no_image-100x100.png" width="40" height="40" alt="" /> <span class="text">Mice and Trackballs</span></a> </li> <li> <a class="link" href="http://rumishop2/component/monitor" > <img class="thumb" src="http://rumishop2/image/cache/no_image-100x100.png" width="40" height="40" alt="" /> <span class="text">Monitors</span></a> </li> <li> <a class="link" href="http://rumishop2/component/printer" > <img class="thumb" src="http://rumishop2/image/cache/no_image-100x100.png" width="40" height="40" alt="" /> <span class="text">Printers</span></a> </li> </ul><ul> <li> <a class="link" href="http://rumishop2/component/scanner" > <img class="thumb" src="http://rumishop2/image/cache/no_image-100x100.png" width="40" height="40" alt="" /> <span class="text">Scanners</span></a> </li> <li> <a class="link" href="http://rumishop2/component/web-camera" > <img class="thumb" src="http://rumishop2/image/cache/no_image-100x100.png" width="40" height="40" alt="" /> <span class="text">Web Cameras</span></a> </li> </ul> </div> This is the source code of Ctrl + U, I mean ... As you can see .. What the code creates every 5 times, but firstly, they are not at level 1 with <ul class="children-list children-list-col clearfix"> , and inside it .. And on top of that, for some reason, they are still created in the main page. Please help and have mercy ..
(($k%5==0) ? "</ul><ul>" :"");? - Dmitriy Simushev 1:16 pm