After several trials of my own, I stumbled upon your code. Thank you for this solution.
Since I don't think an inline php is good either, I took your code and made it into a User Defined Tag called
get_page_haschildren
Code: Select all
global $gCms;
$manager =& $gCms->GetHierarchyManager();
$thisPage = $gCms->variables['page_name'];
$currentNode = &$manager->sureGetNodeByAlias($thisPage);
$nodes = $currentNode->getChildren();
$ph = 0;
if ($currentNode->hasChildren()) {$ph = 1;}
$var = 'page_haschildren';
$smarty->assign($var,$ph);
I used a trick I learned previously -> how to assign a value to a smarty variable inside a UDT.
In my template I use the following code:
Code: Select all
{get_page_haschildren}
{if $page_haschildren}
<div id="page-menu">{menu start_page=$page_alias number_of_levels="2" template="pagemenu"}</div>
{/if}
The call to
get_page_haschildren can be done anywhere as long as it is done
before the use of the
$page_haschildren smarty variable.
The call to the menu module is just what I want to display if the page has children but one can do anything else instead.
Thanks again.