[solved] How to get $node-hierarchy to show more than one digit

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
lampsie
Forum Members
Forum Members
Posts: 38
Joined: Fri Nov 17, 2006 9:25 am

[solved] How to get $node-hierarchy to show more than one digit

Post by lampsie »

Hi,
Is it possible to get {node-hierarchy} to display more than one digit? For example, I have a page structure like so:

1
1.1
1.1.1
1.2

I want to be able to do an {if} in my template to confirm if the current page (1.1.1) is in or below 1.1 in the hierarchy. I have a feeling this should be simple but a few hours of googling later I'm still stumped :(

With the ability to get the full hierarchy level of a current page, I can press ahead with my {if} :)

Thanks,
Lampsie
Last edited by lampsie on Tue May 20, 2008 2:08 pm, edited 1 time in total.
lampsie
Forum Members
Forum Members
Posts: 38
Joined: Fri Nov 17, 2006 9:25 am

Re: How to get $node-hierarchy to show more than one digit

Post by lampsie »

I figured out a way to do this using a different technique...I've posted it below in case anyone else might find it useful:

1) Create a User Defined Tag called e.g. "test" which contains:

global $gCms;
echo $gCms->variables['friendly_position'];


2) In your template, add the following
{capture assign=test}{test}{/capture}
{if ( (substr($test,0,2) == "5.") || ($test == "5")) }

{/if}

...where the 5 is the level of the page in the Admin, and each of its sub-pages are 5.1, 5.1.1 etc.
So, if a visitor clicks into page 5, or any of its sub-pages, the above graphic will get displayed.

This is useful for changing header graphics on a template per section. Plus, I am very sure there must be a neater way to do this ;)

A
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: [solved] How to get $node-hierarchy to show more than one digit

Post by calguy1000 »

Using the CGSimpleSmarty module You would do this:

{$cgsimple->get_root_alias('','root_alias'}}
{if $root_alias == 'the alias of the root I am concerned about'}
    .....
{/if}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Post Reply

Return to “CMSMS Core”