Menü schliessen
Created: April 27th 2012
Last updated: May 1st 2020
Categories: Joomla
Author: Marcus Fleuti

Joomla :: Get the current submenus' parent menu item name, the current page name and set a custom page title based on these informations

Tags:  Joomla
Donation Section: Background
Monero Badge: QR-Code
Monero Badge: Logo Icon Donate with Monero Badge: Logo Text
82uymVXLkvVbB4c4JpTd1tYm1yj1cKPKR2wqmw3XF8YXKTmY7JrTriP4pVwp2EJYBnCFdXhLq4zfFA6ic7VAWCFX5wfQbCC

Note

The following was tested  in Joomla 2.5

Howto

In order to fetch the current submenus' parent menu (item) name add this to your templates' index.php file:

$mydoc = JFactory::getDocument();
$title = $mydoc->getTitle();
$app = JFactory::getApplication();
$this->setTitle( $app->getCfg( 'sitename' ) . ' - ' . $title );  //sets the page title
$menu = &JSite::getMenu();
$active = $menu->getActive();
$pageName = $active->title;  //the current pages' name
$parentId = $active->tree[0];
$parentName = $menu->getItem($parentId)->title;  //the current pages' parent menu name