Menu showing only children or siblings of a page
Posted: Wed May 27, 2009 12:14 pm
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!
Content management as it is meant to be
https://forum.cmsmadesimple.org/
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);
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}