Pagelist only for pages with a certain attribute

Permalink 1 user found helpful
Hey,

how can I make that my pagelist only shows pages with a certain custom attribute checkbox set?

Let's say I have a custom attribute checkbox with "Field of Research A" and one with "Field of Research B" and some sites have either of them checked.

Now I have one "Field of Research overview" where I have pages for each Field of Research. Within these pages I want a pagelist which lists all pages of their Field of Research (means I want to display all pages which have the "Field of Research X" checkbox set in a pagelist).

How could I do this properly? Is a simple pagelist mighty enough for this?

 
kaspera replied on at Permalink Reply
kaspera
All your (custom) attributes are stored in a table called `attributekeys`.

If one of these attribute keys (ak's) are applied to a page, it will show up in a pagelist, prefixed with 'ak_' followed by the `akHandle` value.

So, if you created an attribute 'research_b', you could filter your pagelist as follows:

// You might need the model:
Loader::model('page_list');
$pl = new PageList();
$pl->filter('ak_research_b', 1);
$list = $pl->get();
foreach($list as $pageObj){
    // more code...
}