Luis Martin
Luis Martin

Reputation: 973

Override routes in Joomla

I needed to create an estate agency online on a Joomla 3.x installation. Since I didn't code anything in Joomla since v1.5 and I forgot almost everything, and due to lack of time, I decided to do it by using a plugin for embedding PHP code within articles. So I'm using an article to list properties (real estates), whose alias is "list", and another one whose alias is "property" to view one property.

Everything is up and running, except that I'm using a unique URL for any search, which is a no no for positioning. Search variables are sent through POST, instead of using a SEF URI, because the Joomla router would interfere. To view a property, I do this

www.example.com/property?id=*property_id*

I've been looking for a solution by hacking or overriding the Joomla router, like here: http://docs.joomla.org/J2.5:Creating_a_System_Plugin_to_augment_JRouter

but there's something I'm missing or I don't get it because I can't still prevent the Joomla router from managing itself some routes I'd like to use.

I'd like to use something like

www.example.com/list/mode/rent/type/house/city/fooville/area/downtown

but the second segment is parsed as the article id, and any additional segment leads to a 404 error. What should I do to parse URL's like these?

I was also considering to assume the value of each segment by convention, in order to save myself the segments used to identify the values next to them, but all of them should be optional, so should I stick to a structure like above? It would be overwhelmingly long if I add the rest of search filters.

Upvotes: 2

Views: 2285

Answers (1)

Jan Misker
Jan Misker

Reputation: 2149

If your XML retrieval is done in a custom component you wrote, you could add a router for your component. See here for info on how to do that: http://docs.joomla.org/Supporting_SEF_URLs_in_your_component

You would add a menu link to your component in the site menu with an apropiate alias e.g. list and the Joomla Router would then call your component router for everything after /list/ .

Upvotes: 1

Related Questions