Joomla 3 get parent title of active menu item

web-tiki picture web-tiki · Aug 28, 2013 · Viewed 9.7k times · Source

I found on this thread : get active menu item title how to get the title of active menu item :

$menu = &Jsite::getMenu();
$menuname = $menu->getActive()->title;

but how can I get his parent menu item title?

Answer

Kaerber picture Kaerber · Nov 10, 2013

This should work

$menu = JFactory::getApplication()->getMenu();
$parent = $menu->getItem( $menu->getActive()->parent_id );
$parentname = $parent->title;
$parentlink = JRoute::_( $parent->link . '&Itemid=' . $parent->id );