joer80

Custom PHP code to find selectable pages Page Depth

Recommended Posts

When creating a page field that uses Custom PHP code to find selectable pages , the example shows this:

Return $page->parent->parent->children("name=locations")->first()->children();

It seems this only works if your page is at a specific depth in the page tree that matches the number of parent-> listed here.  If you move the page up a level or down a level, the select will break.  

Is there a way to return a page array without a specified depth?

Share this post


Link to post
Share on other sites

Not a good idea though without limits...can easily overwhelm the server if lots of descendants:

return $page->find('');// will find all descendants

 

Edited by kongondo

Share this post


Link to post
Share on other sites

I think I found the answer..

Instead of using page, you just use pages.  It can be at any depth.

return $pages->find('parent='/pathofparent/');

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.