Menu Manager top level individual classes

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
new2thiscms
Forum Members
Forum Members
Posts: 47
Joined: Thu Nov 09, 2006 7:33 pm

Menu Manager top level individual classes

Post 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
jack4ya
Power Poster
Power Poster
Posts: 294
Joined: Thu Oct 19, 2006 10:07 am

Re: Menu Manager top level individual classes

Post 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?
Last edited by jack4ya on Fri Oct 30, 2009 9:37 pm, edited 1 time in total.
Peciura

Re: Menu Manager top level individual classes

Post by Peciura »

Ajust menu template according your needs:

Code: Select all

class="menu_class_{$node->hierarchy|truncate:1:""}"
jack4ya
Power Poster
Power Poster
Posts: 294
Joined: Thu Oct 19, 2006 10:07 am

Re: Menu Manager top level individual classes

Post 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.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Menu Manager top level individual classes

Post 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.
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.
new2thiscms
Forum Members
Forum Members
Posts: 47
Joined: Thu Nov 09, 2006 7:33 pm

Re: Menu Manager top level individual classes

Post by new2thiscms »

Thank you very much for the help this solved the problem.
Post Reply

Return to “CMSMS Core”