I am not seeing the &Itemid=, the active menu, being added to the URL in Joomla4 like it is with Joomla3. Is this normal behaviour now with Joomla4 and what is the alternative or is it an issue?
My code does this
echo Route::_('index.php?option=com_sales&task=order.editNC&id='.(int) $item->id)
and under Joomla 3 it gets updated to this via
and you can see the
&Itemid=156 is added, with 156 being the id of my currently active menu.
Once I select the link, I am then in the record I wanted to edit and the URL has dropped the record id but the &Itemid is still there.
and this allows the controller to use getActive() to find its way back to calling menu item.
$menu = Factory::getApplication()->getMenu(); $item = $menu->getActive();
Under Joomla 4 the menu id,
&Itemid=156, is not added to the URL
and the value stored in
Input->Data->Itemid now equals 101, which is the Home menu.
/libraries/src/SiteRouter.php appears to be the source of the problem, with lots of changes between J3 and J4 but from everything I have read I can find nothing that says that Itemid was going to be dropped. Maybe it is part of the Legacy vs Modern router change from 3.8.4, with a similar issue occurring back then.
I think it could also be the related to this issue from a couple of months back, Retrieve Active Menu link in Controller (frontend - Joomla4), where the symptoms are the same.
Any help appreciated.