Page list block - List pages at same level

Permalink
Hello everyone,

Im working on a new project. I want to use the Page list block for a feature.

I need the Page list block to list pages on a page with pages from the same level.

I got these options:
everywhere, beneath this page and beneath another page.

Would it be possible to make an option called "Same level as this page", and make it work that way. ?

I hope you understand my question.

Thank you in advance.

87up
 
ScottC replied on at Permalink Best Answer Reply
ScottC
yeah to build this out you'd need to do something like:

global $c;
$cArray = array();  //pageList uses this but builds in the controller
$parentID = $c->getCollectionID();
$parentPage = Page::getByID($parentID);
$cIDArray = $parentPage->getCollectionChildrenArray(TRUE); //gets an arrayofCollectionID;
if(!empty($cIDArray)) foreach($cIDArray as $id){
$cArray[] = Page::getByID($id);
}


Or something really close to that.

You should be able to create a custom template and paste that in the top of the custom view and it "should" work.
87up replied on at Permalink Reply
87up
It works !

I just needed to use $c->getCollectionParentID() instead of $c->getCollectionID().

It should look like this:

global $c;
$cArray = array();  //pageList uses this but builds in the controller
$parentID = $c->getCollectionParentID();
$parentPage = Page::getByID($parentID);
$cIDArray = $parentPage->getCollectionChildrenArray(TRUE); //gets an arrayofCollectionID;
if(!empty($cIDArray)) foreach($cIDArray as $id){
$cArray[] = Page::getByID($id);
}


Thank you once again ScottC for you help. It is most appreciated. :)
fastcrash replied on at Permalink Reply
fastcrash
what if we want to put it in controller, which line i must edit/add?

cause we will have a lot of template, such as most comment, best rating, best view, recent comment, latest article, etc.

so i think its best to put it in controller, it's posible? or if there is filter like 87up said 'Same level as this page', it's really very nice :)

or maybe feature like 'filter by level' ?

i think all of us want to adding block just in default type, and avoid adding block in single page. adding block in single page just special case.


thank you

This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.