I have a page (A) with children (B's) each of these children has children (C's).
On page A I want to display a list of B's with a count next to each which counts the C's belonging to B. Example here: http://bit.ly/1T0TylS
I can do this but I want the count to filter / exclude some of the C pages depending on if a boolean is true on the page.
I did start this question here: http://stackoverflow.com/questions/32099701/silverstripe-3-filtering-filtering-out-dataobjects-in-a-function
And the answer so far was:
public function getGrandChildren() {
$ids = Page::get()->filter(array('ParentID' => $this->ID))->getIDList();
$grandChildren = Page::get()
->filter(array(
'ParentID' => $ids
))
->exclude(array('DealerOnly' => true));
return $grandChildren;
}
but i think this method doesnt work as its not a data object I'm excluding but a page.. It just counts all the pages still.
I'm using a function to get the grand children C's rather than looping as that would not collate them correctly.
This is my grandChildren function:
public function getGrandChildren() {
$ids = Page::get()->filter(array('ParentID' => $this->ID))->getIDList();
$grandChildren = Page::get()->filter(array(
'ParentID' => $ids
));
return $grandChildren;
}
Maybe this is the wrong / complicated way to go about it. Any ideas appreciated.