Steps to reproduce the issue
Having the following menu entry:
ID: 524
Type: Articles->Create Article
Link: index.php?option=com_content&view=form&layout=edit
Execute: echo Route::_('index.php?option=com_content&view=form&layout=edit');
Expected result
- a SEF-friendly URL path according the Joomla menu structure (v.g. /articles/add).
Actual result
- Un-friendly URL path: /component/content/form?layout=edit&Itemid=101 (Itemid 101 refers to the home menu entry).
Additional comments
Execute echo Route::_('index.php?Itemid=524'); and it returns the expected result
This sort of thing seems to be a common problem, considering the number of recent related problems on Joomla stack exchange, eg:
I believe that at least part of the problem stems from the router
preprocess()
function which (as far as I can see) doesn't attempt to find the best match betweenRoute::_()
call andIn other words it seems to go with an
Itemid
if the component associated with the menuitem matches theoption=
parameter of theRoute::_()
call, but doesn't seek to match on other parameters such asview
orlayout
. Those other parameters then need to get included by adding them as query parameters to the URL instead.I think that it's important that SEF URLs are not only functional (in that they get you to the right page), but also aesthetically pleasing (rather than looking awkward with additional
&view=...&layout=...
parameters, which in this case could be avoided if the best menuitem was chosen).(The router has changed from Joomla 3 to Joomla 4 in this area, and it has caused some issues for people who have had printed material produced which quoted the old URLs, or links from other sites. And there doesn't seem to be any Joomla configuration that can maintain the previous URLs, or govern what gets generated as the SEF URL.)
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/41897.