Page 1 of 1

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

Posted: Tue May 20, 2008 12:06 pm
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

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

Posted: Tue May 20, 2008 2:08 pm
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

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

Posted: Tue May 20, 2008 2:18 pm
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}