Jump to content

Paradox


DaveP
 Share

Recommended Posts

<?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?).

post-378-0-88171000-1360845296_thumb.png

Any ideas, or am I being stupid (again)?

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...