Advertisement
dajare

Wolf CMS - list untagged pages

Feb 9th, 2012
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.42 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Creates an array with all pages, sub-pages and their respective levels.
  4.  * It can be used to format the list of pages differently in various views.
  5.  *
  6.  * @param string $parent_id - The id of the parent page.
  7.  * @param int $level - The level where to start.
  8.  * @return array  The array with all the page objects, with an extra 'level' attribute, informing the page's level.
  9. */
  10.     function wfx_getAllChildren($parent_id=0, $level=0) { // begin method
  11.         $children_array = array();
  12.         if(Page::hasChildren($parent_id)) {
  13.             $pages = Page::childrenOf($parent_id);
  14.             foreach($pages as $child) {
  15.                 $child->level = $level;
  16.                 $children_array[] = $child;
  17.                 $children_array = array_merge($children_array, wfx_getAllChildren($child->id, $level+1));
  18.             }
  19.         }
  20.         return $children_array;
  21.     } // End method
  22. ?>
  23.  
  24. <p>Pages without tags:</p>
  25.  
  26. <ul>
  27.   <li>Page link [edit link]</li>
  28. <?php
  29.   $allKids = wfx_getAllChildren('1'); // use page ID for where to start "all-children" listing
  30.   foreach ($allKids as $kid) :
  31. ?>
  32. <?php if (count($kid->tags()) == 0) : ?>
  33.   <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>
  34. <?php endif; ?>
  35. <?php endforeach; ?>
  36. </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement