views:

449

answers:

2

Hello,

Let's say I have this page with pagination:

localhost/fr/users/index/page:1

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:

URL-based language switching...

language param added through app_helper.php

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

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

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

function _setLanguage() {

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

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

SOLUTION:

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'=>'news', 'action'=>'index'));

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

I modified it like this to take all the params:

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

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

Show us the controller code, the view code and some example urls. I've had similar problems in the past, but nobody can help if you don't give us more info.

Leo
+1  A: 

I edited my original post to provide my solution.

Nicolas