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?

<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?

Dutchwave
 
Dutchwave replied on at Permalink Reply
Dutchwave
So if I do this:
<ul>
<?php foreach(array_chunk($pages, 3) as $page ) 
{ ?>
<li>
    <ul>
    <?php foreach ($page as $pages):
      $title = $th->entities($page->getCollectionName());
        ?>   
                 <li class="<?php echo $i++; ?>"><?php echo $title; ?></li>
       <?php endforeach; ?>
    </ul> 
</li>
<? }; ?>
</ul>

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.
Dutchwave replied on at Permalink Best Answer Reply
Dutchwave
Ok got it...

<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.
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi Dutchwave,

This does look useful, thank you.