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?
How to show all pages below a specific parent?
- Oskar Rough
- Forum Members
- Posts: 40
- Joined: Tue Aug 26, 2008 9:45 pm
- Location: Denmark
Re: How to show all pages below a specific parent?
Hi,
Create a UDT named list_children
Put {list_children} in the content of the parent and all children will be shown in a list.
Hope this helps,
Rolf
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>";
}
Hope this helps,
Rolf

- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
- Oskar Rough
- Forum Members
- Posts: 40
- Joined: Tue Aug 26, 2008 9:45 pm
- Location: Denmark
Re: How to show all pages below a specific parent?
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?
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?
- Rednes
- 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?
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]);
}
}

Re: How to show all pages below a specific parent?
Could also use this
or this
Code: Select all
{menu template="simple_navigation.tpl" start_page=$page_alias}
Code: Select all
{menu template="simple_navigation.tpl" childrenof=$content_id}
- Rednes
- 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?
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
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.