Multiple Page Type filters within a Page List block

Permalink
Hi all,

I've run into a challenge where by I could do with creating a page list block that filters not just by one Page Type but rather two, so that the resultant list of pages are of either Page Type X or Page Type Y.

I've delved into the core page_list code and can see where the filterByCollectionTypeID function is used to set a filter on the query but I get a little lost as this transitions into the executable code within the core database_item_list.php.

From my limited knowledge, I'm not quite sure as to how I should override the code to include this logical OR into this filter.

Any guidance or help would be appreciated.

Regards,

Dan

dbaggs
 
tofraser replied on at Permalink Best Answer Reply
tofraser
This is an abbreviated version of what can be found here:
http://www.weblicating.com/doku/doku.php?id=cheatsheet...

<?php
  Loader::model('page_list');
  $pl = new PageList();
 //Filters by page type handles. $ctHandle can be array of page type handles.
  $pl->filterByCollectionTypeHandle($ctHandle); 
  // Get the page List Results 
  $pages = $pl->getPage(); //Get all pages that match filter/sort criteria.
// Display Page Name and Description
  foreach ($pages as $page){
    echo $page->getCollectionName();
    echo $page->getCollectionDescription();
  }
?>
dbaggs replied on at Permalink Reply
dbaggs
Thanks Tim,

It was right under my nose I guess. I've now overridden the Page List Block controller getPageList method and utilised the filterByCollectionTypeHandle method instead of the filterByCollectionTypeID for the scenario where I needed to handle it differently.

Works great.

Regards,

Dan
tofraser replied on at Permalink Reply
tofraser
Awesome!
wbargent replied on at Permalink Reply
What file did you place the code in?
tofraser replied on at Permalink Reply
tofraser
Something like this could be placed into a page template.