Dev License: This installation of WHMCS is running under a Development License and is not authorized to be used for production use. Please report any cases of abuse to abuse@whmcs.com

Joomla - Getting the Default Menu Link Print

  • 2

The following example shows how to use the getMenu() class to pull the default menu item.  We build the valid url by appending the ever so elusive "Itemid" to the query.  If your website does not need to track the menu item then you can simply pull the $defaultMenu->link value.

/***************************************************
 * Pull the Default Menu item and Build the URL
 ***************************************************/
$defaultMenu = JFactory::getApplication()->getMenu()->getDefault();
$defaultMenuUrl = 'index.php?'.http_build_query(array_merge($defaultMenu->query,array('Itemid'=>$defaultMenu->id)));
$defaultMenuLink = JRoute::_($defaultMenuUrl);
$defaultMenuReturn = base64_encode($defaultMenuLink);

Was this answer helpful?

« Back

Powered by WHMCompleteSolution