简体   繁体   English

在Joomla的超车路线

[英]Override routes in Joomla

I needed to create an estate agency online on a Joomla 3.x installation. 我需要在Joomla 3.x安装上在线创建一个房地产代理。 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. 由于从v1.5开始我没有在Joomla中编写任何代码,而且由于时间紧缺,我几乎忘记了所有内容,因此我决定使用插件将PHP代码嵌入文章中来实现。 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. 因此,我正在使用一篇文章来列出属性(房地产),其别名为“ list”,而另一项别名为“ property”,以查看一个属性。

Everything is up and running, except that I'm using a unique URL for any search, which is a no no for positioning. 一切正常,除了我对任何搜索都使用唯一的URL,这对定位没有影响。 Search variables are sent through POST, instead of using a SEF URI, because the Joomla router would interfere. 搜索变量是通过POST发送的,而不是通过SEF URI发送的,因为Joomla路由器会产生干扰。 To view a property, I do this 要查看属性,请执行此操作

www.example.com/property?id= *property_id* 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 我一直在寻找通过入侵或覆盖Joomla路由器的解决方案,例如: 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. 但是有些东西我不见了,或者我不明白,因为我仍然无法阻止Joomla路由器自己管理一些我想使用的路由。

I'd like to use something like 我想使用类似

www.example.com/list/mode/rent/type/house/city/fooville/area/downtown 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. 但第二段被解析为商品ID,任何其他段都会导致404错误。 What should I do to parse URL's like these? 我应该怎么解析这些URL?

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. 如果我添加其余的搜索过滤器,那将是非常长的时间。

If your XML retrieval is done in a custom component you wrote, you could add a router for your component. 如果XML检索是在编写的自定义组件中完成的,则可以为该组件添加一个路由器。 See here for info on how to do that: http://docs.joomla.org/Supporting_SEF_URLs_in_your_component 有关如何执行此操作的信息,请参见此处: 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 eg list and the Joomla Router would then call your component router for everything after /list/ . 您可以在站点菜单中使用适当的别名(例如list)将菜单链接添加到组件,然后Joomla路由器会在/ list /之后为所有组件调用组件路由器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM