I developed a component in Joomla! 3, and I used JRoute::_()
& router.php to make urls search-engine-friendly. something like this :
/component/products/WIFI-IP-Phone/list-3
So I decided to replace /component/products
with a clean alias, And I created a menu with a clean alias to the component home page. now, all the link I have inside the component ( generated with JRoute::_()
) are like this : /escene/WIFI-IP-Phone/list-3
and its perfect, its exactly what I want, But ... I'm using JRoute::_()
in three different modules, and I generate links with that, the problem is that generated links in these modules when I'm in the home page or any other page except the component pages, are different with the generated links in these module when I'm in the component pages.
When I'm in the home page or other : /component/products/WIFI-IP-Phone/list-3
When I'm in my component pages : /escene/WIFI-IP-Phone/list-3
Any body can explain the reason Or help me to make all urls like /escene/WIFI-IP-Phone/list-3
??
This is because the functions you write in components router.php get executed for the links when the page displaying is of the same component. But there is a way to accomplish this task.
1. First create a new menu in the menu manager and create all links in this menu.
2. Publish this menu but do not assign any position.
3. In this way you would get a sef url for each link.
if(JFactory::getConfig()->get('sef')) {
echo 'My sef url';
} else {
echo 'Dynamic url';
}
In this way Joomla will do your url parsing by detecting your component through the alias stored. Let me know if you have any further query.