The Principles of Successful Freelancing »

How to Detect active menu in Joomla

Sometime in the Joomla code, you want to determine which menu item is the active one.   You can do so like...

<?php
$theMenu = JSite::getMenu();
$theActiveMenu = $theMenu->getActive();
echo $theActiveMenu->alias;
?>

It should return the alias of the active menu item.  The alias is what you had set in the Joomla admin control panel for the menu item.