Get Name of Parent Menu Item in Joomla

Tiny Tots' MenuHow to get the name of the current page’s parent from the menu (i.e., get the title of the page one level up) in Joomla 1.5:

$menu = JSite::getMenu();
$parent = $menu->getItem($menu->getActive()->parent)->name;

$menu->getActive()->parent returns the id of the parent, which is why you then have to pass that id to $menu->getItem([id])->name. It would be nice to have a parent() function so that you would only need $menu->getActive()->parent()->name, but I quibble.

Photo: University of Washington Libraries Digital Collections, via Flickr Commons

8 thoughts on “Get Name of Parent Menu Item in Joomla

  1. Pingback: Joomla! | Warren Tang's Blog

Leave a comment