Joomla 1.6 自定义 SEF router.php - 我的组件无法读取 url 变量
嗨,我有一点问题。我为 Joomla 1.6 编写了一个自定义组件,并且刚刚为我的组件编写了一个自定义 router.php 文件,这样我就可以拥有“漂亮的”SEF url。
例如从
http://www.domain.com/index.php?option=com_my_component&view=list&id=1:test
TO
http://www.domain.com/com_my_component/list/1-test
非常好,是的!但我现在遇到的问题是,当我使用这段代码获取 url 变量:
$id = JRequest::getVar('id', 'blank');
并将其打印出来时,我得到:
blank
当我应该获取 id 值时。看来现在设置了 SEF url,我的组件无法检索 id 等实际驱动数据库驱动的网站。请有人给我一些关于我可能做错了什么的见解。
非常感谢。
Hi I have a bit of a problem. I have written a custom component for Joomla 1.6 and I have also just written a custom router.php file for my component so I can have 'pretty' SEF urls.
E.g. from
http://www.domain.com/index.php?option=com_my_component&view=list&id=1:test
TO
http://www.domain.com/com_my_component/list/1-test
Very nice, yes! But the problem I am now having is that when I use this piece of code to get a url variable:
$id = JRequest::getVar('id', 'blank');
And print it out, I get:
blank
when I should get the id value. It seems that having now set the SEF urls that my component cannot retrieve the ids and such that actually drive a database driven website. Please could someone give me some insight as to what I might be doing wrong.
Many thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是在 router.php 的“ParseRoute”函数中,我没有检查和设置正确的 url 段。此函数用于检查段,然后根据其在 url 中的位置设置正确的变量和正确的段值。
The problem was that in my "ParseRoute" function in my router.php I was not checking and settings the correct url segments. This function is used to check the segments and then set the correct variable with the right segment value depending on the location of it in the url.