esedic
9/11/2016 - 5:25 PM

PHP function for getting active/home menu in Joomla

PHP function for getting active/home menu in Joomla

<?php

	public static function getActive(&$params)
	{
		$menu = JFactory::getApplication()->getMenu();
		$lang = JFactory::getLanguage();

		// Look for the home menu
		if (JLanguageMultilang::isEnabled())
		{
			$home = $menu->getDefault($lang->getTag());
		}
		else
		{
			$home  = $menu->getDefault();
		}

		return $menu->getActive() ? $menu->getActive() : $home;
	}
}