Page 1 of 1

How to show all pages below a specific parent?

Posted: Mon May 17, 2010 10:25 am
by Oskar Rough
Hi,

I'd like to show all pages below a specific parent. Everyone of these pages are using the same template, if that matters. How would that be possible?

Re: How to show all pages below a specific parent?

Posted: Mon May 17, 2010 10:30 am
by Rolf
Hi,

Create a UDT named list_children

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="sectionlinks">';
  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>";
}
Put {list_children} in the content of the parent and all children will be shown in a list.

Hope this helps,

Rolf  :)

Re: How to show all pages below a specific parent?

Posted: Mon May 17, 2010 10:36 am
by Oskar Rough
How's that for a fast answer, thank you!

It works just fine, however, what I meant was the actual content of the pages (incl. content blocks). Would that be possible, too?

The UDT also shows inactive and "do not show in menu" pages. Is there a way to check for this?

Re: How to show all pages below a specific parent?

Posted: Thu Jul 29, 2010 9:12 am
by Rednes

Code: Select all

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

$nodes = $currentNode->getChildren();

if ($currentNode->hasChildren()) {
 
 foreach ($nodes as $node) {

     $content= $node->getContent();
    
$contentx = $contentops->LoadContentFromAlias($content->Alias());    
print_r($contentx->mProperties->mPropertyValues[content_en]);
 

 }



}

took me only 15 minutes to figure this one out  :D

Re: How to show all pages below a specific parent?

Posted: Thu Jul 29, 2010 9:30 am
by Jos
Could also use this

Code: Select all

{menu template="simple_navigation.tpl" start_page=$page_alias}
or this

Code: Select all

{menu template="simple_navigation.tpl" childrenof=$content_id}

Re: How to show all pages below a specific parent?

Posted: Tue Aug 17, 2010 10:46 am
by Rednes
Using this UDT creates an issue where I can't get smarty tags to work on subpages.

A tag ouputs as text and not initializing smarty.

update: See the solution here: http://forum.cmsmadesimple.org/index.ph ... 612.0.html