[solved] unique class for one menu item?

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
toolman
Forum Members
Forum Members
Posts: 51
Joined: Wed Sep 12, 2007 5:10 pm

[solved] unique class for one menu item?

Post by toolman »

Hi there,

Is it possible to give a unique class to one menu item? I want to give the 3rd menu item a different class to the rest of the menu items. Is this possible?
Last edited by toolman on Thu Aug 12, 2010 10:59 pm, edited 1 time in total.
uniqu3

Re: unique class for one menu item?

Post by uniqu3 »

You have a few options to add class to your menumanager template, for example you could use:

class="menu-{$node->hierarchy|truncate:1:""}" which would result in class="menu-numberofthepage"

or

class="{$node->titleattribute}" whichwould result class="titleattribute" which can be add in the options tab of page edit.

or

class="{$node->alias}" which resultes in class="aliasofyourpage"
toolman
Forum Members
Forum Members
Posts: 51
Joined: Wed Sep 12, 2007 5:10 pm

Re: unique class for one menu item?

Post by toolman »

Hi,

thanks for the reply.

I have tried {$node->titleattribute}, but I am not quite sure where I should add the class.

I have tried this, but it didn't work:

[php]

{foreach from=$nodelist item=node}
{if $node->depth > $node->prevdepth}
{repeat string='' times=$node->depth-$node->prevdepth}
{elseif $node->depth prevdepth}
{repeat string=' ' times=$node->prevdepth-$node->depth}

{elseif $node->index > 0}
{/if}
{if $node->parent == true or ($node->current == true and $node->haschildren == true)}
titleattribute}">
titleattribute}" {elseif $node->current == true}

haschildren == true}
titleattribute}">
titleattribute} {$node->titleattribute}"  {elseif $node->type == 'sectionheader' and $node->haschildren == true}
{$node->menutext} {elseif $node->type == 'separator'}
{else}

[/php]
uniqu3

Re: unique class for one menu item?

Post by uniqu3 »

Hi,

i assume you have used css_menu.tpl as your example according to the classes i see, so here is a sollution:
{if $count > 0}


{foreach from=$nodelist item=node}
{if $node->depth > $node->prevdepth}
{repeat string='' times=$node->depth-$node->prevdepth}
{elseif $node->depth prevdepth}
{repeat string='' times=$node->prevdepth-$node->depth}

{elseif $node->index > 0}
{/if}
{if $node->parent == true or ($node->current == true and $node->haschildren == true)}

titleattribute)} {$node->titleattribute}{/if}" {elseif $node->current == true}

titleattribute)} {$node->titleattribute}{/if}" {elseif $node->haschildren == true}

titleattribute)} {$node->titleattribute}{/if}" {elseif $node->type == 'sectionheader' and $node->haschildren == true}
{$node->menutext}{elseif $node->type == 'separator'}
{else}

type != 'sectionheader' and $node->type != 'separator'}
{if $node->target}target="{$node->target}" {/if}
href="{$node->url}">{$node->menutext}
{elseif $node->type == 'sectionheader'}
>{$node->menutext}
{/if}
{/foreach}
{repeat string='' times=$node->depth-1}




{/if}
As you can see i used {if isset($node->titleattribute)} {$node->titleattribute}{/if} this means if something is entered there it will show up otherwise not, why like this, for example if current already has class "menuactive" if only {node->titleatribute} would be used, there would be space befor " it the title attribute is not set.
toolman
Forum Members
Forum Members
Posts: 51
Joined: Wed Sep 12, 2007 5:10 pm

Re: unique class for one menu item?

Post by toolman »

Many many thanks for your help! I really appriciate it :)
Post Reply

Return to “Layout and Design (CSS & HTML)”