开发者

cakephp reverse routing conflicts with pagination logic

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.

  1. it doesn't pass the brand parameter
  2. 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


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.

    $this->Paginator->options(array
            ('url'=> array(
                'controller' => 'products', 
                'action' => 'index',
                'brand'=>$this->params['brand']
   )));  

That does the job :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜