UDT to display list of active sub pages [Solved]

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
deschnell
Forum Members
Forum Members
Posts: 48
Joined: Fri Jun 27, 2008 5:27 am
Location: Lethbridge

UDT to display list of active sub pages [Solved]

Post by deschnell »

So I'm almost there, thanks to this UDT code - http://wiki.cmsmadesimple.org/index.php ... rrent_page

Code: Select all

global $gCms;
$manager =& $gCms->GetHierarchyManager();
$thisPage = $gCms->variables['page_name'];
$currentNode = &$manager->sureGetNodeByAlias($thisPage);

$nodes = $currentNode->getChildren();

if ($currentNode->hasChildren()) {
  echo '<ul class="customlist">';
  foreach ($nodes as $node) {
     
     $content= $node->getContent();
     $url = $content->GetURL();
    if ($url == "#") { /* section header has no link by default */
      $url = "index.php?page=".$content->Alias();
    }
    echo "<li><a href=\"".$url."\">".$content->MenuText()."</a> </li>";

  }
  echo "</ul>";
}
But - it displays inactive pages as well, which isn't what I want. I need it to filter out the inactive pages, but not too sure which calls I need to make - I'm a newbie^2 when it comes to this kind of smarty stuff. There are a couple examples on that same page linked above working with active pages, but not too sure how to incorporate into the above code.
Last edited by deschnell on Thu Oct 13, 2011 10:11 pm, edited 1 time in total.
Jos
Support Guru
Support Guru
Posts: 4019
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

Re: UDT to display list of active sub pages

Post by Jos »

Is there a reason that you can not simply use the menu tag for this?

Code: Select all

{menu childrenof=$page_alias}
MenuManager help says:
(optional) childrenof="" - This option will have the menu only display items that are descendants of the selected page id or alias. i.e: {menu childrenof=$page_alias} will only display the children of the current page.
User avatar
deschnell
Forum Members
Forum Members
Posts: 48
Joined: Fri Jun 27, 2008 5:27 am
Location: Lethbridge

Re: UDT to display list of active sub pages [solved]

Post by deschnell »

never thought about it, and does work. I assumed at first I needed to replace "page_alias" with the page name/alias/ID - but that doesn't work. the variable needs to read #page_alias. Thanks!!
Post Reply

Return to “Modules/Add-Ons”