What is the best way show total number of:
- childpages
- parent pages
This code shows the total number of ALL published pages:
Code: Select all
<?php echo count($pages->getList(1, -1, true)); ?>
Code: Select all
<?php echo count($pages->getList(1, -1, true)); ?>
Code: Select all
<?php
// Count ALL dogzones
// Page number of the paginator, the first page is 1
$pageNumber = 1;
// The value -1 tell to Bludit to returns all the pages on the system
$numberOfItems = -1;
// Only get the pages with the satus published
$onlyPublished = true;
// Get the list of keys of pages
$items = $pages->getList($pageNumber, $numberOfItems, $onlyPublished);
$count = 0;
foreach ($items as $key) {
// buildPage function returns a Page-Object
$page = buildPage($key);
$children = $page->children();
// Each child is a Page-Object
foreach ($children as $child) {
$count++;
}
}
// print the result
echo '<p>' . $count . '</p>';
?>