I am just creating a custom mod_menu in Joomla 3

I wonder if anyone could be so kind and explain what this block of code means since I can not find any reference to the parameter $item->params->get('aliasoptions) also what does this block of code actually do to the menu item? - (line 37 - code taken from default.php in tmpl folder from mod_menu)

    $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';
    }

Any explanation to this would be most helpful, I am wondering if it's actually needed?

有帮助吗?

解决方案

Thats the corresponding function from the helper.php

case 'alias':
// If this is an alias use the item id stored in the parameters to make the link.
$item->flink = 'index.php?Itemid=' . $item->params->get('aliasoptions');
break;

So if you look at the function in default.php you will see this piece of code:

foreach ($list as $i => &$item) :
$class = 'item-'.$item->id;

and following with an if clause and after that the code you are asking for.

So what it basically does (in my understanding):

Use the item id defined in itemparameters (basically its just the item id xD ) if the link is just an alias for another menu item. Without it Joomla shouldnt be able to set the correct active menu links.

You can set Menu Item Aliases by choosing them in the Menu Item Type selection: "System Links -> Menu Item Alias", when creating or editing menu items ;)

I hope this helps ^^

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top