如何在启用 SEF 的情况下查找非 SEF URL(Joomla 1.5)?
我知道您可能不会遇到很多这样的问题...
我正在开发一个组件,我希望能够在启用 SEF 时处理非 SEF URL,无论是内置 SEF 还是其他东西像sh404sef。
Joomla 是否将原始非 SEF URL 存储在任何地方 即。 index.php?com=com_fred&view=主页?
我发现任何激活的 SEF 都会将 JURI::getInstance() 值更改为 SEF 等效值。 我还发现 $REQUEST['URI'] 值不适用于所有平台/服务器等。
感谢您的帮助
I know you probably don't get many questions like this...
I am working on a component that I want to be able to deal with the non-SEF URLs whilst SEF is enabled, whether it be the built-in SEF or something like sh404sef.
Does Joomla store the ORIGINAL non-SEF URL anywhere ie. index.php?com=com_fred&view=homepage?
I've found that any SEF activated, changes the JURI::getInstance() value to the SEF equivilant.
I've also found the the $REQUEST['URI'] value does not work on all platforms/servers etc.
Thanks for any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
将
GET/POST
请求中的所有变量获取到一个数组中。 此时,您还可以在生成 URL 字符串之前修改这些值。如果您确实需要 URL 字符串,可以通过以下方式获取:
希望有帮助!
Get all vars from the
GET/POST
request into an array. At this point you may also modify the values before generating the URL string.If you really need the URL string, you can obtained with:
Hope it helps!
我回到这段代码并再次尝试,但给了我一些错误,所以我根据我之前用这个新答案制定的先前答案部分地重新设计了它(在 Joomla!3.4.5 上工作得很好)
Joomla! API 文档:
JInput
-JUri
上一个答案:< /强>
谷歌搜索我发现了这个:
我'已经用 Joomla 测试过了! 3.4.4 及其工作正常! 不知道1.5能不能用
I came back to this code and tried again but gave me some errors, so I've reworked it partially based on the previous answer I've formulated before with this new one (working nice on Joomla! 3.4.5)
Joomla! API Docs:
JInput
-JUri
PREVIOUS ANSWER:
Googling around I found this:
I've tested it with Joomla! 3.4.4 and its working fine! Dunno if it can work with 1.5
您可以使用 JRequest::get(true) 从 URL 获取所有查询参数的数组。 不过,请注意,我还没有对其进行足够的检查,无法知道它是否只返回 GET 参数,还是返回所有 REQUEST 参数(我认为更有可能)。 但是,它可能对您正在寻找的内容有所帮助。
You can use JRequest::get(true) to get an array of all the query parameters from the URL. A quick note though, I haven't checked it enough to know if it only returns GET parameters or it does all REQUEST parameters (which I think is more likely). It might, however, help with what you're looking for.
对于菜单项,它存储在“jos_menu”表的“link”列中(但 itemid 不在该字符串中 - 它是“id”列)。
对于其他任何事情,它可能不会存储在数据库中,但通常可以很容易地计算出来,尤其是对于核心组件。 使用第三方组件可能会有点麻烦,但您可以查看大多数组件的 MVC 架构来解决这个问题。
否则,您始终可以在开发站点上关闭 SEF/为此创建一个开发站点。
您对某个特定组件感到好奇吗?
For menu items, it's stored in the 'jos_menu' table, in the 'link' column (but the itemid is not in this string - it's the 'id' column).
For anything else, it's probably not stored in the database, but can normally be worked out pretty easily, especially with core components. It can be a little bit of a pain with third party components, but you can look through the MVC architecture of most components to figure it out.
Otherwise, you could always turn off SEF on your dev site/create a dev site for this.
Is there a specific component that you're curious about?
我在这里发布的链接:
Joomla URL:一篇文章没有本身没有漂亮的 URL?
为 Joomla 1.5 中的 URL 提供了一个非常好的“速成课程”
The link that I posted here:
Joomla URLs: An article doesn't have a pretty URL by itself?
provides a very good "crash course" for URLs in Joomla 1.5
您无需对非 SEF URL 执行任何特殊操作。 即使您打开了 SEF URL,如果有人使用非 SEF URL 访问站点,Joomla 仍将显示正确的页面。 组件中处理 SEF URL 的部分(路由器)仅告诉 Joomla 如何使用 URL 信息来确定要显示的内容。 当出现非 SEF URL 时,Joomla 只会像平常一样解析查询字符串。
对于任何给定的组件,URL都是这样构建的 -
index.php?option=com_name&view=XXXX&id=1111&Itemid=11111
You don't have to do anything special for non-SEF URLs. Even if you have SEF URLs turned on, Joomla will still display the correct page if someone access the site with a non-SEF URL. The portion of your component that handles SEF URLs, the router, only tells Joomla how to use the URL information to determine what to display. When presented with a non-SEF URL Joomla just parses the query string as it normally would.
For any given component, the URL is built like this -
index.php?option=com_name&view=XXXX&id=1111&Itemid=11111