How to show all pages below a specific parent?

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
User avatar
Oskar Rough
Forum Members
Forum Members
Posts: 40
Joined: Tue Aug 26, 2008 9:45 pm
Location: Denmark

How to show all pages below a specific parent?

Post 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?
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

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

Post 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  :)
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
Oskar Rough
Forum Members
Forum Members
Posts: 40
Joined: Tue Aug 26, 2008 9:45 pm
Location: Denmark

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

Post 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?
User avatar
Rednes
Forum Members
Forum Members
Posts: 85
Joined: Wed Apr 08, 2009 1:09 pm
Location: Rotterdam, The Netherlands

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

Post 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
Jos
Support Guru
Support Guru
Posts: 4019
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

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

Post 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}
User avatar
Rednes
Forum Members
Forum Members
Posts: 85
Joined: Wed Apr 08, 2009 1:09 pm
Location: Rotterdam, The Netherlands

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

Post 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
Last edited by Rednes on Tue Aug 17, 2010 2:58 pm, edited 1 time in total.
Post Reply

Return to “CMSMS Core”