hi everyone. I need help customizing a menu template so that a class of "last-child" is added to each last, second-level menu item.
The HTML is structured like this:
TOP LEVEL #1
TOP LEVEL #2
SECOND LEVEL ITEM #1 UNDER TOP LEVEL ITEM #2
LAST SECOND LEVEL ITEM UNDER TOP LEVEL ITEM #2
The end goal is to have the red tags be generated with a class of "last-child", in addition to any other classes which the template is currently giving them.
The SMARTY template which is generating the menu is below:
{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)}
current == true}
haschildren == true}
type == 'sectionheader'}
{$node->menutext}
{elseif $node->type == 'separator'}
{else}
type != 'sectionheader' and $node->type != 'separator'}
href="{$node->url}" {if $node->accesskey != ''}accesskey="{$node->accesskey}" {/if}{if $node->tabindex != ''}tabindex="{$node->tabindex}" {/if}{if $node->titleattribute != ''}title="{$node->titleattribute}"{/if}{if $node->target ne ""} target="{$node->target}"{/if}>{$node->hierarchy}: {$node->menutext}
{elseif $node->type == 'sectionheader'}
>{$node->hierarchy}: {$node->menutext}
{/if}
{/foreach}
{repeat string="" times=$node->depth-1}
{/if}
I know nothing about smarty, so can someone please tell me how i have to change the template to add those classes.
smarty fix to add last-child class to menu
Re: smarty fix to add last-child class to menu
I think this won't be easy.. there's no parameter like $node->nextdepth.
Just curious, whats the purpose of this class?
Just curious, whats the purpose of this class?
Re: smarty fix to add last-child class to menu
the point of this was to deal with incompatibility in the css :last-child psuedo class. I already wrote a javascript fix, but figured doing it on the server's side would be better (because the user might have javascript disabled).
Re: smarty fix to add last-child class to menu
Look to smarty manual (.last)studip101 wrote: hi everyone. I need help customizing a menu template so that a class of "last-child" is added to each last, second-level menu item.
Alby
-
- Forum Members
- Posts: 28
- Joined: Thu Jan 08, 2009 1:28 pm
Re: smarty fix to add last-child class to menu
Have this problem too, can anybody help to achieve this with the minimal_menu.tpl ?