Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Creates an array with all pages, sub-pages and their respective levels.
- * It can be used to format the list of pages differently in various views.
- *
- * @param string $parent_id - The id of the parent page.
- * @param int $level - The level where to start.
- * @return array The array with all the page objects, with an extra 'level' attribute, informing the page's level.
- */
- function wfx_getAllChildren($parent_id=0, $level=0) { // begin method
- $children_array = array();
- if(Page::hasChildren($parent_id)) {
- $pages = Page::childrenOf($parent_id);
- foreach($pages as $child) {
- $child->level = $level;
- $children_array[] = $child;
- $children_array = array_merge($children_array, wfx_getAllChildren($child->id, $level+1));
- }
- }
- return $children_array;
- } // End method
- ?>
- <p>Pages without tags:</p>
- <ul>
- <li>Page link [edit link]</li>
- <?php
- $allKids = wfx_getAllChildren('1'); // use page ID for where to start "all-children" listing
- foreach ($allKids as $kid) :
- ?>
- <?php if (count($kid->tags()) == 0) : ?>
- <li><?php echo Page::linkById((int)$kid->id()); ?> <?php if (AuthUser::isLoggedIn() && AuthUser::hasPermission('administrator')) : ?>[<a href="<?php echo BASE_URL.'admin/page/edit/'.$kid->id(); ?>">edit</a>]<?php endif; ?></li>
- <?php endif; ?>
- <?php endforeach; ?>
- </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement