Hierarchy Manager: Getting the root for each node
Hierarchy Manager: Getting the root for each node
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
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
Actually I did abuse the MenuMager for this one ... here is how it works:
Just in case somebody needs it ...
Regards,
Nils
Code: Select all
{foreach from=$nodelist item=node}
{if $node->current == true}{$node->hierarchy|truncate:1:""}{/if}
{/foreach}
Regards,
Nils
Re: Hierarchy Manager: Getting the root for each node
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)
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)
- Elijah Lofgren
- Power Poster

- Posts: 811
- Joined: Mon Apr 24, 2006 1:01 am
Re: Hierarchy Manager: Getting the root for each node
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.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}
I've been adding mine to this page: http://wiki.cmsmadesimple.org/index.php ... nu_Managertsw 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)
It would be cool it other people added theirs.
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. 
Re: Hierarchy Manager: Getting the root for each node
what does this render on page or HTML/view source?
mark
mark
- Elijah Lofgren
- Power Poster

- Posts: 811
- Joined: Mon Apr 24, 2006 1:01 am
Re: Hierarchy Manager: Getting the root for each node
It would render the first digit of $node->hierarchy. For example if you have the following layout:mark wrote: what does this render on page or HTML/view source?
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.nils73 wrote: 1. Home
2. Services
2.1. First
2.2. Second
3. Contact
3.1. Address
3.2. Form
I'm guessing this is what it does based on the code. I haven't tried it.
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. 
Re: Hierarchy Manager: Getting the root for each node
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:
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
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
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'}">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); }Regards,
Nils
Re: Hierarchy Manager: Getting the root for each node
Untested, but this might help for situations where you do go over 10.
Code: Select all
{$node->hierarchy|truncate:2:""|strip:"."}
-
streever
Re: Hierarchy Manager: Getting the root for each node
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
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
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...
-
streever
Re: Hierarchy Manager: Getting the root for each node
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.
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.

