0

I want to create a Joomla menu-item that changes its name after it has been clicked on and I want to be abled to insert code (in php??) in a if then else style (if name = oldname then elseif name = newname then).

  • I would suggest using jQuery for something like this – Lodder Jul 7 '15 at 10:36
1

There is no way for inserting php code after jQuery/Javascript event. If you want to change menu item name after click you should work on this file:

/modules/mod_menu/tmpl/default_component.php

You should use Template Override to create alternative layout for mod_menu. Then in default_component.php (or your new layout) add code working as follows:

  • If current menu item is item you want modify add a marker in JSession
  • Check if current item that mod_menu will display in default_component.php is item you want to modify
  • If this is the item and there is a marker in JSession (if the item was clicked) change its name

Alternative way is to use Cookie as a marker and add/create it when Java Script Click event is triggered on menu item you want to modify (so basically you omit first step and change last one)

Few useful functions:

Get current menu item (menu item for current page):

$menu = JFactory::getApplication()->getMenu()->getActive()

Get current menu item ID:

JFactory::getApplication()->input->getInt('Itemid')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.