Factory::getApplication()->getMenu() deprecated

50 views
Skip to first unread message

Bernhard Woehrlin

unread,
Oct 7, 2021, 2:17:31 PM10/7/21
to Joomla! General Development
I am used to get the current item id like this:
$itemId = Factory::getApplication()->getMenu()->getActive()->id;

In Joomla 3.10 Factory::getApplication()->getMenu() seems to be deprecated. How should I rewrite the code to get the current item id?

Carlos Rodríguez

unread,
Oct 7, 2021, 9:03:05 PM10/7/21
to Joomla! General Development
No, still the same, even for J4, and is not deprecated:

$app = Factory::getApplication();
$itemId = $app->getMenu()->getActive()->id;

Bernhard Woehrlin

unread,
Oct 8, 2021, 7:11:43 AM10/8/21
to Joomla! General Development

Hm. Maybe I misinterpret the API documentation?
https://api.joomla.org/cms-3/classes/JApplication.html#method_getMenu 

Carlos Rodríguez

unread,
Oct 8, 2021, 10:36:24 AM10/8/21
to Joomla! General Development
Reply all
Reply to author
Forward
0 new messages