adrianmak Posted January 10, 2016 Share Posted January 10, 2016 as topic Link to comment Share on other sites More sharing options...
SiNNuT Posted January 10, 2016 Share Posted January 10, 2016 Could you elaborate a bit? Because I read it as if you want to check if a page has a (certain?) parent? if ($page->parentID == 0) echo "no parent"; Link to comment Share on other sites More sharing options...
Macrura Posted January 10, 2016 Share Posted January 10, 2016 well every page is a child of a page except for the homepage. otherwise these may be of help: http://cheatsheet.processwire.com/page/built-in-fields-reference/page-parent/ http://cheatsheet.processwire.com/page/built-in-fields-reference/page-parent_id/ http://cheatsheet.processwire.com/page/built-in-methods-reference/page-parent-selector/ Link to comment Share on other sites More sharing options...
adrianmak Posted January 11, 2016 Author Share Posted January 11, 2016 Let say, I have following page structure Home +-------Sample page 1 +----Child page 1.1 +----Child page 1.2 +----Child page 1.3 +----Child page 1.4 +----Child page 1.5 +-------Sample page 2 +----Child page 2.1 +----Child page 2.1 +----Child page 2.1 +-------Sample page 3 +----Child page 2.1 +----Child page 2.2 +----Child page 2.3 +----Child page 2.4 While viewing a page say "Child page 2.1", How to know it is a child page of Sample page 2 , Sample page 1 or Sample page 3 Anyway, Macrura has given several api links which may fit for my requirment. Link to comment Share on other sites More sharing options...
kongondo Posted January 11, 2016 Share Posted January 11, 2016 ? $page->parent; http://cheatsheet.processwire.com/?filter=parent See also: $page->parentID; $p = $page->parent;// here, $page->parent will give you the parent page object of the current page or nullpage if it does not have one echo $p->title; if($p->id == $someOtherID)// do whatever.... 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now