DaveP Posted February 14, 2013 Posted February 14, 2013 <?php $parent_page = $pages->get('/path/to/parent/'); echo "<p>{$parent_page->title}->numChildren {$parent_page->numChildren}</p>"; echo "<p>{$parent_page->title}->children->count {$parent_page->children->count()}</p>"; ?> (My parent page is called 'Sites'.) Would, you'd think, generate the same number of children for both methods of determining that number (wouldn't it?). Any ideas, or am I being stupid (again)?
diogo Posted February 14, 2013 Posted February 14, 2013 numChildren is returning all pages and children->count is returning only the published pages 1
Soma Posted February 14, 2013 Posted February 14, 2013 There was exactly same question 1 week ago... ok again http://processwire.com/talk/topic/2584-numchildren-vs-children/?hl=%2Bnumchildren+%2Bcount $page->numChildren returns ALL children count. count($page->children); //or $page->children->count(); return only viewable pages by the user, which mean NOT: unpublished, hidden or non-accessible pages. 1
diogo Posted February 14, 2013 Posted February 14, 2013 Soma, maybe this could be added in the cheatsheet? 1
DaveP Posted February 14, 2013 Author Posted February 14, 2013 Thanks for the explanation and sorry for the duplicate question.
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