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.
The
/component/abcis generated by the Joomla routing. Your component router.php will take care of the parameters which the component handles, so your/our-component/?id=32may be translated into/our-component/my-id32-alias. It's not desirable that any component can tweek the basic routing on which all other components are based, and that's why you only can make-up part of the URL using router.phpMaybe you can investigate how to augment the router using a system plugin, but I think it is not what you are looking for.
http://docs.joomla.org/J2.5:Creating_a_System_Plugin_to_augment_JRouter
I've read it many times, but I find it hard to understand.