In J4, I have a menu item (in main menu) loading a single article and I've added a unique class via the menu Page Display >> Page Class. It has an alias of "commercial" and when used from the front end the URL is /commercial.

I have created another menu with a menu item that is an alias item pointing to the above menu item. The alias on this menu item is "commercial-info".

However, when visiting the link on the front-end, the page class is not used and the URL is /?itemid=223 (the id number of the alias menu item (not the one it points to).

Also, the <body> gets a class added no-layout no-task dir-ltr itemid-233 (as well as a number of other miscellaneous classes added).


The custom module that is creating the links is building the links using this code:

$menuItemURL = Route::_("index.php?Itemid={$menuItem->id}");

So the question is, how can I get the REAL URL using Route::_ when the menu is an alias? (The above Route::_ works fine for all other menu types other than alias).

  • I have come up with code to manually lookup the menu that the alias is pointing to and build the appropriate link/url; however, I'm wondering if there is any way to do that using just the Route:: function. I've not found any of help in the Joomla docs on this. May 2, 2023 at 20:52

1 Answer 1


It's in the menuitem params, as 'aliasoptions'. This holds the itemid of the menuitem which the alias menuitem points to. So if you have your alias menuitem as $menuItem then do

$itemid = $menuItem->getParams()->get('aliasoptions');
$url = Route::_("index.php?Itemid={$itemid}");

I'm pretty sure this isn't in the joomla docs, I just found it by inspecting the menuitem object in a debugger. It should really be documented in the Menu and Menuitems API Guide but the number of such param values that you'd need to list is rather offputting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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