I can see all over the internet people are talking over this.
While using JRoute::_($URL)
we are forced to calculate the Itemid
first and then append it to the input URL like:
JRoute::_('index.php?option=com_abc&view=xyz&id=32'.'&Itemid='.$itemid);
However, it is always desirable to calculate the Itemid
automatically from within the Joomla core router from the given URL.
Since Joomla 1.5 through 3.2 today, the
JRouterSite::_buildSefRoute
or the latest JRouterSite::buildSefRoute
has not changed significantly.
I can see in the codes at /libraries/cms/router/site.php
file that to build the desired format sef URL it is mandatory to include Itemid=XXX
in the passed URL. Otherwise
JRoute::_('index.php?option=com_abc&view=xyz&id=32');
will generate a URL something similar to
`/component/abc/?view=xyz&id=32`
unlike the desired
/our-component/?id=32
where our-component
is the menu alias for the menu item pointing to
index.php?option=com_abc&view=xyz
I know that the later half ?view=xyz&id=32
can be handled by using custom router.php file per component. But the component base URL /component/abc
is out of scope for that custom router.php
Please somebody advise that am I right at this thought or I am missing something big. Also advise me for how to overcome this issue.