Menu showing only children or siblings of a page
Menu showing only children or siblings of a page
How to make a menu, which will show only the children of a page if they exist, otherwise only the siblings of a page? Thanks in advance!
Re: Menu showing only children or siblings of a page
Hi,
i had the same problem.
Try the following:
1. Create Userdefined Tag - Name 'Hierarchy' (as in the handbook described)
>> $smarty->assign('h_level', count($base) * 1) - !!!
2. put the following code in your page template
What we do is try to get a menu with the Param '$NewLevel' which represents the Level of the current pages Children.
If this fails the value $count will be 0 and we should try to list the nodes on the same level as the current page ($h_level').($count is set by the menumanger and represents the number of Nodes in the menu)
In the code Listed above i do NOT list toplevel Nodes!! It starts at atleast Level 2!
I hope this helps.
i had the same problem.
Try the following:
1. Create Userdefined Tag - Name 'Hierarchy' (as in the handbook described)
Code: Select all
global $gCms;
$pos = $gCms->variables['position'];
$base = explode('.', $pos);
$smarty->assign('h_toplevel', $base[0] * 1);
$smarty->assign('h_parent', $base[ (count($base) > 1) ? count($base)-2 : 0 ] * 1);
$smarty->assign('h_this', $base[count($base)-1] * 1);
$smarty->assign('h_level', count($base) * 1);
2. put the following code in your page template
Code: Select all
{hierarchy}
{assign var="NewLevel" value=$h_level+1}
{assign var='count' value=0}
{if $NewLevel > 1}
{menu template='AnyTemplateYouWish' number_of_levels='1' collapse='1' start_level="$NewLevel" show_root_siblings='1'}
{if $count == 0 && $NewLevel > 2}
{menu template='AnyTemplateYouWish' number_of_levels='1' collapse='1' start_level="$h_level" show_root_siblings='1'}
{/if}
{/if}
If this fails the value $count will be 0 and we should try to list the nodes on the same level as the current page ($h_level').($count is set by the menumanger and represents the number of Nodes in the menu)
In the code Listed above i do NOT list toplevel Nodes!! It starts at atleast Level 2!
I hope this helps.