Page 1 of 1
Hierarchy Manager: Getting the root for each node
Posted: Tue May 09, 2006 3:10 pm
by nils73
Hi there,
I am trying to change an image in the header by using a unique id on the body tag. Let's assume my structure looks like this:
1. Home
2. Services
2.1. First
2.2. Second
3. Contact
3.1. Address
3.2. Form
Is it possible to assign if home is active and if either Services, First or Second are active and of course if Contact, Address or Form is active?
I thought about "abusing" MenuManger to achieve this, but I didn't get it right. Then I read about Hierarchy Manager which has been introduced in 0.12 but for this one I couldn't find any documentation. Any help would be highly appreciated.
Regards,
Nils
Re: Hierarchy Manager: Getting the root for each node
Posted: Wed May 17, 2006 12:50 pm
by nils73
Actually
I did abuse the MenuMager for this one ... here is how it works:
Code: Select all
{foreach from=$nodelist item=node}
{if $node->current == true}{$node->hierarchy|truncate:1:""}{/if}
{/foreach}
Just in case somebody needs it ...
Regards,
Nils
Re: Hierarchy Manager: Getting the root for each node
Posted: Wed May 17, 2006 1:13 pm
by tsw
Great find nils.
It might be better to collect these into wiki. just have to think for a place for these (maybe in the tips and trics section)
Re: Hierarchy Manager: Getting the root for each node
Posted: Wed May 17, 2006 1:22 pm
by Elijah Lofgren
nils73 wrote:
Actually
I did abuse the MenuMager for this one ... here is how it works:
Code: Select all
{foreach from=$nodelist item=node}
{if $node->current == true}{$node->hierarchy|truncate:1:""}{/if}
{/foreach}
Thanks Nils! I had been wondering how to get just the first digit of $node->hierarchy, but I didn't know about truncate. Thanks for showing me.
tsw wrote:
It might be better to collect these into wiki. just have to think for a place for these (maybe in the tips and trics section)
I've been adding mine to this page:
http://wiki.cmsmadesimple.org/index.php ... nu_Manager
It would be cool it other people added theirs.

Re: Hierarchy Manager: Getting the root for each node
Posted: Wed May 17, 2006 1:27 pm
by Dr.CSS
what does this render on page or HTML/view source?
mark
Re: Hierarchy Manager: Getting the root for each node
Posted: Thu May 18, 2006 1:19 am
by Elijah Lofgren
mark wrote:
what does this render on page or HTML/view source?
It would render the first digit of $node->hierarchy. For example if you have the following layout:
nils73 wrote:
1. Home
2. Services
2.1. First
2.2. Second
3. Contact
3.1. Address
3.2. Form
and the current page is "Services", "First, or "Second" then a "2" would be outputted. If the current page is "Contact, Address, or Form" then a "3" would be outputted.
I'm guessing this is what it does based on the code. I haven't tried it.

Re: Hierarchy Manager: Getting the root for each node
Posted: Thu May 18, 2006 4:50 am
by nils73
Elijah,
right you are. It just outputs the first char of the node-elemente by truncating the whole string to 1 --- so it would not be suitable for websites with long main-menus but then Jacob Nielsen says you should not use more than 7 ... so truncate should do the trick almost every time.
In my case I needed it to have a CSS signature attached to the body so that it is like this in CMSMS-templates:
Code: Select all
</__body id="cat{cms_module module='menumanager' template='getSection'}">
Which means I have created a template called "getSection" in MenuManager which then renders as follows:
1. Home
2. Services
2.1. First
2.2. Second
3. Contact
3.1. Address
3.2. Form
By using CSS you can then specify a lot of thing, such as a different header-image for each section for example by using
Code: Select all
#cat3 div.header { background: url(imageforsection3.jpg); }
which would then be a different image for all header-divs that have been assigned the CSS signature for cat3 (Contact, Address, Form). But I can think of many other cases where this turns out to be very handy ...
Regards,
Nils
Re: Hierarchy Manager: Getting the root for each node
Posted: Thu May 18, 2006 9:56 am
by Ted
Untested, but this might help for situations where you do go over 10.
Code: Select all
{$node->hierarchy|truncate:2:""|strip:"."}
Re: Hierarchy Manager: Getting the root for each node
Posted: Sun Jan 07, 2007 6:33 pm
by streever
YES!!!!
this is basically
exactly
what i am looking for, except i need to give each main button it's own class
oh, please, someone, help

Re: Hierarchy Manager: Getting the root for each node
Posted: Sun Jan 07, 2007 6:44 pm
by Dr.CSS
In menu manager the template you are using add class="a{node->id}" which should output class="a15" for home page, you need a letter in front of it a it doesn't like numbers only...
Re: Hierarchy Manager: Getting the root for each node
Posted: Sun Jan 07, 2007 7:30 pm
by streever
Hi Mark,
Thank you!!! Thank you!!!!
I was kind of thinking that, and just testing it... you saved me a lot of additional testing trying to figure out if it would work or not.