Page 1 of 1

Menu Manager top level individual classes

Posted: Fri Oct 30, 2009 8:24 pm
by new2thiscms
Hi everyone,

I have the latest version of CMSMS installed and am trying to adapt the menu manager to work with a design that has a requirement for each top level link to have its own class. I adjusted the template to only use the li tag and none of the the other associated class. I also found a cycle values tag which kind of worked but instead of listing them in the exact order it did the first two classes followed by a random 2 others and so on. This made me think that maybe the cycle values is meant for only 2 items.

Does anyone know a way to assign specific classes to the top level of a drop down menu. I have been searching the forums for a couple hours now and I appreciate any help.

Thanks,

Chris

Re: Menu Manager top level individual classes

Posted: Fri Oct 30, 2009 9:32 pm
by jack4ya
I had a similar thing. My solution, though not nice, does work.
But I had 4 groups and no more, so I could hardcode it a bit.

Make multiple menu template and give each toplevel it's own class.

(dirty code but I think you understand)
{menu template=a start_element=1}
{menu template=b start_element=2}
{menu template=c start_element=3}
{menu template=d start_element=4}
Downside is you need to make multiple templates

With layouts attached to menu groups:
Split you pages in groups. Each group will represent a menu(group)
Now code it "read" to friendly position of a particulair page.
So page 2.1 will have a parent "2"
With this number, when assigned, you put it in the template and then call it with css.
Some code to illustrate:

in a page/template:
{assign var='styleposition' value=$friendly_position|truncate:1:''}
So the styleposition is: {$styleposition}
(on page 2.3.x whatever the output wil be "2")

so a code like



Can now be used with the {$styleposition} :




It might not be exactly what you wany/need, but it might give you a starting point

*) disclaimer: I'm not a programmer, there are most likely better ways?

Re: Menu Manager top level individual classes

Posted: Fri Oct 30, 2009 9:46 pm
by Peciura
Ajust menu template according your needs:

Code: Select all

class="menu_class_{$node->hierarchy|truncate:1:""}"

Re: Menu Manager top level individual classes

Posted: Fri Oct 30, 2009 9:52 pm
by jack4ya
See! It can be quicker and (c)leaner!  ;D
At least i was on course with the last bit.  ::)

Valuable lesson today for me.

Re: Menu Manager top level individual classes

Posted: Sat Oct 31, 2009 12:26 am
by calguy1000

Code: Select all

class="menu_depth_{$node->depth}"  
different class for each level, no problems.

want each node to have it's own class:

Code: Select all

class="menu_{$node->alias}"
want each node to have it's own class, but only on the top level...

Code: Select all

{if $node->depth == 1}class="menu_{$node->alias}" {/if}
it really is that simple.  it just takes some time investment to learn and understand smarty, and to learn how to use the variables and data that is at your fingertips.

Re: Menu Manager top level individual classes

Posted: Mon Nov 02, 2009 3:07 pm
by new2thiscms
Thank you very much for the help this solved the problem.