Does anyone know how can I get the current menu model in Joomla 4? In 2.5/3.X I was using this code:

    $model = JModelLegacy::getInstance( 'MenusModelItem' )

But this is not working anymore in 4. I kinda cannot find any way to get it in J4.

Regards, Radek

1 Answer 1


To get Menu item in Joomla 4 you can get the Item From the Factory like

use Joomla\CMS\Factory;
$menu = Factory::getApplication()->getMenu();
$active = $menu->getActive();

getActive() will give the curent Menu Item, you can use other methods getDefault() or getItem() as per your need.

You can get Menu items with menu type as

$items = $menu->getItems('menutype', 'mainmenu');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.