Cakephp pagination problem with next/previous


Staff member
Let's say I have this page with pagination:


I see the correct results for page 1 based on how I have defined the paginate var in my controller. But when I click the next button, the url change to page:2 but the results don't change and are the same as page:1, same thing for page:3, page:4 and so on...

If I first sort a column, let's say username, then I can use the previous/next link without any problem, the data change on each page.

The only thing I can think of that could cause me problem is that I use a language param in my urls but I have no idea how to fix this...

I'm currently using Cake 1.2.5. I also tried with 1.3 beta with same results.

Ok so here's my Users controller code:

var $paginate = array('limit'=>'5');
function index() {
$this->User->recursive = 0;
$this->set('users', $this->paginate());

I'm using teknoid tutorial for language switching:

<a href="" rel="nofollow noreferrer">URL-based language switching...</a>

language param added through app_helper.php

function url($url = null, $full = false) {
    if(!isset($url['language']) &amp;&amp; isset($this-&gt;params['language'])) {
        $url['language'] = $this-&gt;params['language'];

     return parent::url($url, $full);

and language switching done using a method in the app_controller.php:

function _setLanguage() {

    if ($this-&gt;Cookie-&gt;read('lang') &amp;&amp; !$this-&gt;Session-&gt;check('Config.language')) {
        $this-&gt;Session-&gt;write('Config.language', $this-&gt;Cookie-&gt;read('lang'));
    else if (isset($this-&gt;params['language']) &amp;&amp; ($this-&gt;params['language']
         !=  $this-&gt;Session-&gt;read('Config.language'))) {     

        $this-&gt;Session-&gt;write('Config.language', $this-&gt;params['language']);
        $this-&gt;Cookie-&gt;write('lang', $this-&gt;params['language'], null, '20 days');


After setting up yahoo boss site and noticing that paging was working flawlessly, I looked more closely at my code and found the problem was inside my routes.php.

I had this:

Router::connect('/news', array('controller'=&gt;'news', 'action'=&gt;'index'));

Router::connect('/:language/news', array('controller'=&gt;'news', 'action'=&gt;'index'), array('language'=&gt;'[a-z]{2}'));

I modified it like this to take all the params:

Router::connect('/news/*', etc...

Router::connect('/:language/news/*', etc...