cakephp反向路由与分页逻辑冲突
我有一个新问题:) 我将简要解释我想要实现的目标。现在我有一个看起来像这样的网址。
/products/index/brand:figleaves
我希望它看起来像这样
/brand/figleaves
通过编写以下路由规则我得到了我想要的。
Router::connect('/brand/:brand/*', array('controller' => 'products', 'action' => 'index'));
一切都很顺利,但后来我发现分页逻辑已被破坏。 如果我点击“下一页”,我会被重定向到 URL /products/index/page:2
。
- 它不会传递品牌参数
- ,而是重定向回 products_controller,而不是我在路由规则中定义的 url。
事实上,我需要将其作为 url /brand/figleaves/page:2
。
奇怪的是,如果我浏览到 /products/index/brand:figleaves
并单击“下一步”,然后我会被重定向到 /brand/figleaves/page:2
。这该如何解释呢?
我希望得到一些帮助:)
亲切的问候, 洛朗
I've a new question :)
I'll briefly explain what I'm trying to achieve. Right now I have an url that looks like this.
/products/index/brand:figleaves
I want this to look like this
/brand/figleaves
By writing the following route rule I get what I want.
Router::connect('/brand/:brand/*', array('controller' => 'products', 'action' => 'index'));
Everything goes fine, but then I discovered the pagination logic has been destructed.
If I click on 'next page' I get redirected to the url /products/index/page:2
.
- it doesn't pass the brand parameter
- it redirects back to the products_controller and not to the url I defined in the route rule.
In fact I'd need this as url /brand/figleaves/page:2
.
Strange thing is if I browse to /products/index/brand:figleaves
and click on Next, then I get redirected to /brand/figleaves/page:2
. How can this be explained?
I'd appreciate some help with this :)
Kind Regards,
Laurent
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于那些对我如何解决这个问题感兴趣的人。
我只是在我看来的分页器中定义了一些选项并显式传递了值,如下所示。
这样就可以完成工作了:)
For those interested in how I solved this.
I just defined some options in the paginator in my view and passed the value explicitly, like this.
That does the job :)