Page 1 of 1
Determine site hierarchy level of current page
Posted: Thu Apr 16, 2009 2:00 am
by pomfret
Can someone explain how I go about determining if the current page's hierarchy level >=3?
I'm trying to add a secondary subtitle to pages that are 3 levels or deeper in the site page structure.
Thanks,
Brian
Re: Determine site hierarchy level of current page
Posted: Thu Apr 16, 2009 4:43 am
by RonnyK
Do you mean the
$node->depth -- Depth (level) of this node in the current menu
parameter that is in the MenuManager to check its level?
Ronny
Re: Determine site hierarchy level of current page
Posted: Thu Apr 16, 2009 12:55 pm
by pomfret
RonnyK wrote:
Do you mean the
$node->depth -- Depth (level) of this node in the current menu
parameter that is in the MenuManager to check its level?
Ronny
I tried all the MenuManager options. However, since the navigation is split across separate menu calls, MenuManager does seem to think anything is more than 2 levels deep (which would be correct at the point of the {menu} calls in the template).
What I'm thinking now is creating a UDT to split $gCms->variables['friendly_position'] into an array, then counting the number of items in the array to determine page depth (ie. 2.2 = two levels, 1.3.2 = three levels). With all the other info readily available, I had hoped I was overlooking a much simpler method of doing the same.
Thanks,
Brian
Re: Determine site hierarchy level of current page
Posted: Thu Apr 16, 2009 5:01 pm
by pomfret
OK. So, I went the UDT route and seem to be in good shape. I'd still be interested in hearing if there's an easier way to go about all this:
My UDT (get_page_position):
Code: Select all
global $gCms;
$hierarchy = count(explode(".", $gCms->variables['friendly_position']));
$smarty->assign('page_level', $hierarchy);
The, in my template:
Code: Select all
{get_page_position}
{if ($page_level gte "3")}
{$cgsimple->get_page_menutext($cgsimple->get_parent_alias(),'')} ::
{/if}
{title}
Brian