Search code examples
phpjoomla

Getting Menu Parameters from Joomla


I'm trying to get parameters from the menu table in Joomla. What I have below is working in the sense that it is returning the parameters.

 $menu =   &JSite::getMenu();
 $item =  $menu->getItem($menuId)->params;
 print $items;

However, It's returning them in plain text, as if I had just queried the column and returned the params contents.

Can someone tell me how to return this as an Object or Array so that I can use something like:

$myParam = $item->getParams('theParamIwant');

Solution

  • You need to use the JParameter class to read the params. Try something like this:

    $item = $menu->getItem($menuId);
    $params = new JParameter($item->params);
    $myParam = $params->get('theParamIwant');