0
votes

I'm using Joomla 3.1.

I'm having a strange issue with my router.php file in my component.

I have a basic router.php file, not doing much as yet, before I add my features I need to get it actually working on basic stuff first.

I have a menu item with the component set as the item type. Viewing the homepage shows the view I created.

For the links, if I use the following:

echo JRoute::_('index.php?option=com_vacations&view=test&cat=123');

I get this:

http://mysite/en/component/vacations/?view=test&cat=123

I do not want the "component/vacations" shown however. So I've tried this:

echo JRoute::_('index.php?view=test&cat=123');

And I get:

http://mysite/en/?view=test&cat=123

Seemingly correct, however the second method never touches my router.php. This means I cannot alter it to display something like:

http://mysite/en/test/123

How can I fix it so that the url is parsed through router.php?

1
Does the second URL (http://mysite/en/?view=test&cat=123) show the desired component's view?MasterAM
Yes it does. I think I may have figured out the problem, if I set a menu item (besides the homepage) to my component then the links work fine. It is only when it is from the homepage that the links work as mentioned above. e.g. http://mysite/en/menualias/ will generate the links correctly when viewed.hyarion

1 Answers

1
votes

When you use JRoute to create links to your application always create full query like in first code:

echo JRoute::_('index.php?option=com_vacations&view=test&cat=123');

Router will work as router when you actually write routing functions. Without those your rooter will return links using default joomla routing markup (like this http://mysite/en/component/vacations/?view=test&cat=123). Look into code from any joomla component like com_weblinks. It will help you to understand whole process. You can find it here: /components/com_weblinks/router.php