Joomla get menu item id
23,934
$app = JFactory::getApplication();
$menu = $app->getMenu()->getActive()->id;
echo $menu;
Hope this is what you're looking for
Author by
Tom
Updated on July 21, 2022Comments
-
Tom almost 2 years
I have a component that has a simple payment form. I just want to get the current menu item id. I've tried several things to get the id.
//get the active menu item id $app = JFactory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); $activeId = $active->id; JLog::add('active id is: '.$activeId); //I get nothing returned $currentMenuId = JSite::getMenu()->getActive()->id ; JLog::add('menu id is: '.$currentMenuId); //I get nothing returned //try to see what the current url is $currenturl = JURI::current(); JLog::add('current url is: '.$currenturl); //I get mysite.com/index.php
I use
$activeId
code in my plugins without problems but it doesn't work in my component. What am I missing?