Page List - array_chunk (orbit slider)
Permalink
The aim is to display 3 items at a time from a page list in Orbit slider.
After every 3 items, it will need a closing tag </ul>
I found that array_chunk does the trick, but I haven't got a clue how to display the attributes values. When I try I get for example "Call to a member function getCollectionName() on a non-object".
How to the change the following (stripped) code, in order do add attribute values to it?
Or is there a different better way?
After every 3 items, it will need a closing tag </ul>
I found that array_chunk does the trick, but I haven't got a clue how to display the attributes values. When I try I get for example "Call to a member function getCollectionName() on a non-object".
How to the change the following (stripped) code, in order do add attribute values to it?
<ul> <?php foreach(array_chunk($pages, 3) as $page ) { $title = $th->entities($page->getCollectionName()); ?> <li> <ul> <?php foreach($page as $pages) { ?> <li class="test">test</li> <?php } ?> </ul> </li> <? }; ?> </ul>
Or is there a different better way?
Ok got it...
Pretty useful if you ask me.
<ul> <?php foreach(array_chunk($pages, 3) as $pages3 ) { ?> <li> <ul> <?php foreach ($pages3 as $page): $title = $th->entities($page->getCollectionName()); ?> <li class="<?php echo $i++; ?>"><?php echo $title; ?></li> <?php endforeach; ?> </ul> </li> <? }; ?> </ul>
Pretty useful if you ask me.
Hi Dutchwave,
This does look useful, thank you.
This does look useful, thank you.
I get this error: Call to a member function getCollectionName() on a non-object
But If I turn around $page as $pages > $pages as $page.
The output shows double.