The Techjoomla Blog

Stay updated with all the latest happenings at Techjoomla. From news about the developments in your favourite extensions to Tips & Tricks about the Joomla CMS, Framework & Development.
Font size: +
1 minute reading time (125 words)

How to access Joomla menu parameters anywhere inside Joomla code?

How to access Joomla menu parameters anywhere inside Joomla code?

 

Screenshot shows menu item parameters for Joomla - Content - Featured Articles Menu

 

Here are two code snippets inside Joomla that lets you access menu parameters anywhere inside Joomla!

 

1. To access Current Menu parameters

$app = JFactory::getApplication();
// Get active menu
$currentMenuItem = $app->getMenu()->getActive();
// Get params for active menu
$params = $currentMenuItem->params;
// Access param you want
$yourParameter = $params->get('yourParameter');

 

2. To access Menu parameters from a known Itemid

$app = JFactory::getApplication();
// Get Itemid from URL
$input  = JFactory::getApplication()->input;
$itemId = $input->get->get('Itemid', '0', 'INT');
// Get menu from Itemid
$menuItem = $app->getMenu()->getItem($itemId);
// Get params for menuItem
$params = $menuItem->params;
// Access param you want
$yourParameter = $params->get('yourParameter');

 

That was easy-peasy! Wasnt it?

Feel free to add comments!

4
×
Stay Informed

When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.

Exclusive Discount on EasySocial and EasyBlog for ...
Celebrate Independence Day with Techjoomla!
 

Blog Topics