views:

136

answers:

2

I don't seem to be able to use a custom route with pagination. The URL of the blog should be http://www.domain.com/en/page:2. However, the links generated by the PaginateHelper (prev and next), keep adding the controller and action, so that the URL looks like http://www.domain.com/posts/index/en/page:2.

The route config is quite simple:

Router::connect(
    '/:lang/*',
    array(
        'controller' => 'posts',
        'action' => 'index'
    ),
    array(
        'lang' => '[a-z]{2}',
        'pass' => array(
            'lang'
        )
    )
);

I set this in the view:

$paginator->options(
    array(
        'url' => $this->passedArgs
    )
);

and also to set the path manually not using an array

this happens with Cake 1.33

Any help would be greatly appreciated!

+1  A: 

It seems prev and next method of Paginator helper doesn't use default options. That's why

$paginator->options(
    array(
        'url' => $this->passedArgs
    )
);

doesn't work. You can set it on prev and next method directly. For example:

$paginator->prev('<< Previous', array('url' => $this->passedArgs));

Hope that help.

Jamal Aziz
Thanks for your answer! Unfortunately it didn't solve my problem (still the same: Cake keeps adding the controller + action to the URL where it shouldn't). I will track that towards core in the next days ..
harpax
aargh .. I found it: passedArgs did only contain the var `lang`. When I added the controller and action to the index it worked. Thanks again
harpax