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?
[solved] unique class for one menu item?
[solved] unique class for one menu item?
Last edited by toolman on Thu Aug 12, 2010 10:59 pm, edited 1 time in total.
Re: unique class for one menu item?
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"
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?
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]
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?
Hi,
i assume you have used css_menu.tpl as your example according to the classes i see, so here is a sollution:
i assume you have used css_menu.tpl as your example according to the classes i see, so here is a sollution:
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.{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}
Re: unique class for one menu item?
Many many thanks for your help! I really appriciate it 
