joomla

Joomla Hack to Use Menu Item Aliases with Menu Images

When we make one menu item an alias of another menu item, we do not mean to simply duplicate the same menu item type.  We mean to set the menu item type of one to “Alias” (at the bottom of the menu item type list) and choose the other menu item as the target of the alias.  If you don’t do this, it creates duplicate content on separate URLs and doesn’t properly highlight the active TNB menu item.

However, when using menu images for the menu items instead of text, aliases break this by trying to use the menu image from the target menu item.  Here’s the fix.

Step #1: Add the Menu Image parameter to the Alias/Menulink menu type.

In order to accomplish this I simply edited the following file:
administrator/components/com_menus/models/metadata/menulink.xml

And added in the menu image parameter as shown below:

<?xml version="1.0" encoding="utf-8"?>
<metadata>
<state>
<name>Menu Link</name>
<description>Menu Link parameters...</description>
<params>
<param name="menu_item" type="menuitem" state="1" disable="menulink, separator" label="Menu Item" description="Menu Item to link to..." />
<param name="menu_image" type="imagelist" directory="/images/stories" hide_default="1" default="" label="Menu Image" description="PARAMMENUIMAGE" /> 
</params>
<advanced />
</state>
</metadata>

Step #2: Hack the front-end code to use the new parameter instead of the target menu item’s parameter

Go go to /modules/mod_mainmenu/helper.php and after line 292, add the following 2 lines…

$tmp->params = $item->params;
$tmp->ionly = $item->ionly;

Now it’s working fine to set menu items to aliases and choose the menu image.

One downside to this is that it is Joomla core code hacking, and will get overwritten when the site receives Joomla updates.  If someone knows how to implement this using template overrides, please edit this article and add your instructions here.  Thanks!

Table of Contents

0 0 votes
Article Rating
Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
valeriy
valeriy
14 years ago

Thank you!
It is work

1
0
Would love your thoughts, please comment.x
()
x