Determine site hierarchy level of current page

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
pomfret
Forum Members
Forum Members
Posts: 14
Joined: Wed Dec 31, 2008 7:19 pm
Location: Connecticut, USA

Determine site hierarchy level of current page

Post 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
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm
Location: Raalte, the Netherlands

Re: Determine site hierarchy level of current page

Post 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
pomfret
Forum Members
Forum Members
Posts: 14
Joined: Wed Dec 31, 2008 7:19 pm
Location: Connecticut, USA

Re: Determine site hierarchy level of current page

Post 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
pomfret
Forum Members
Forum Members
Posts: 14
Joined: Wed Dec 31, 2008 7:19 pm
Location: Connecticut, USA

Re: Determine site hierarchy level of current page

Post 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
Post Reply

Return to “CMSMS Core”