Can I add code to menu li items?

General questions relating to Joomla! 2.5. Note: All 1.6 and 1.7 releases have reached end of life and should be updated to 2.5. There are other boards for more specific help on Joomla! features and extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Locked
bogomir
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Fri Jul 12, 2013 11:09 am

Can I add code to menu li items?

Post by bogomir » Fri Jul 12, 2013 11:23 am

I use a completely in CSS programmed menu on my page, which uses :hover to open the submenus. I don't want to use any JS library like mootools or jquery, because I had some conflicting code between these two libraries on some pages, where different modules were not working which each other. Long story short: I need to make the menu work on smartphones/tablets, which have by design some challenges with :hover. Allegedly one way to solve this, would be to add 'onmouseover=""' to each <li> item, the menu is built with. Unfortunately I have no idea, how to inject that code to each <li> item of my menu, because all the menu html code is controlled/generated by Joomla. Be aware, that even menu items, which have submenus, are links themselves (that's another reason why I used :hover)! Does anyone have a tip/hint/whatever?

Thanks!

certico
Joomla! Explorer
Joomla! Explorer
Posts: 301
Joined: Tue Apr 10, 2012 5:00 pm
Location: London UK
Contact:

Re: Can I add code to menu li items?

Post by certico » Fri Jul 12, 2013 12:14 pm

The menu output will be generated by the module that you are using.
Have a look in /modules/mod_menu/ (or whichever menu module you are using).

There have a look in the tmpl folder, default.php, there will be a foreach loop in there that echos out each menu item, you can add your onmouseover there.

Best way would be to do this as a template override so your change isnt lost on future updates.
http://docs.joomla.org/How_to_override_ ... omla!_core


Locked

Return to “General Questions/New to Joomla! 2.5”