Reputation: 61
in Joomla menu module php - default.php,How can i find the second li submenu and add class name 'the-secondsubmenu' into it?
the output will looks like this:
<ul class="nav">
<li>
<a></a>
<ul>
<li class="the-secondsubmenu">
<a></a>
</li>
</ul>
</li>
</ul>
i'm add this line in foreach
if($item->level < 2): $counter += count($item); endif;
and add these
if ($item->deeper)
{
$class .= ' deeper';
}
elseif($item->deeper && $counter === 2){
$class .= ' deeper the-secondsubmenu';
}
THE PHP
foreach ($list as $i => &$item)
{
if($item->level < 2):
$counter += count($item);
endif;
$class = 'item-' . $item->id;
if (($item->id == $active_id) OR ($item->type == 'alias' AND $item->params->get('aliasoptions') == $active_id))
{
$class .= ' current';
}
if (in_array($item->id, $path))
{
$class .= ' active';
}
elseif ($item->type == 'alias')
{
$aliasToId = $item->params->get('aliasoptions');
if (count($path) > 0 && $aliasToId == $path[count($path) - 1])
{
$class .= ' active';
}
elseif (in_array($aliasToId, $path))
{
$class .= ' alias-parent-active';
}
}
if ($item->type == 'separator')
{
$class .= ' divider';
}
if ($item->deeper)
{
$class .= ' deeper';
}
elseif($item->deeper && $counter === 0){
$class .= ' deeper the-secondsubmenu';
}
these code not working,
As always, your assistance is appreciated!
Upvotes: 0
Views: 507
Reputation: 953
if you write this code, the second part won't be executed because the test includes the same test as the first block.
if ($item->deeper) {
$class .= ' deeper';
}
elseif ($item->deeper && $counter === 2) {
$class .= ' deeper the-secondsubmenu';
}
maybe you should try to put the second block first :
if ($item->deeper && $counter === 2) {
$class .= ' deeper the-secondsubmenu';
}
elseif ($item->deeper) {
$class .= ' deeper';
}
Upvotes: 0