Posted on 9/3/09 by Felix Geisendörfer
if you find yourself in a situation where you need to write a template that splits up a list of items in multiple rows with each row having a fixed amount of items, here is a simple solution:
<?php while ($items): ?>
<?php for ($i = 0; ($item = array_shift($items)) && $i < 4; $i++): ?>
<?php echo $item['Item']['title']; ?>
<?php endfor; ?>
<?php endwhile; ?>
This will put 4 items in each row and a smile on your face for not having to write very ugly code to achieve the same : ).
-- Felix Geisendörfer aka the_undefined
You can skip to the end and add a comment.
This post is too old. We do not allow comments here anymore in order to fight spam. If you have real feedback or questions for the post, please contact us.