Page 1 of 1

[solved] unique class for one menu item?

Posted: Wed Aug 11, 2010 12:43 pm
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?

Re: unique class for one menu item?

Posted: Wed Aug 11, 2010 1:32 pm
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"

Re: unique class for one menu item?

Posted: Thu Aug 12, 2010 4:47 pm
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]

Re: unique class for one menu item?

Posted: Thu Aug 12, 2010 6:07 pm
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.

Re: unique class for one menu item?

Posted: Thu Aug 12, 2010 10:59 pm
by toolman
Many many thanks for your help! I really appriciate it :)