Weird CakePHP (1.3) Pagination component behaviour
$this->data
. And it says exactly the same as before: working perfectly fine with the gender ($this->data['users']['gender']
go through all the pagination pages), but the other parameters just got lost once I try to navigate away.
The thing is that there isn't any difference between the filter gender
and the other ones, either on the controller side or in the view (both are select inputs).
On a more technical side, here's a bit of my code:
//In the controller function
if (!empty($this->data['users']['gender'])) {
$conditions['gender'] = $this->data['users']['gender'];
}
if (!empty($this->data['users']['country_id'])) {
$conditions['city_id'] =
$this->User->City->find(
'list',
array(
'conditions' => array(
'country_id' => $this->data['users']['country_id']),
'fields' => 'City.id'));
}
if (!empty($this->data['users']['city_id'])) {
if($this->data['users']['city_id'] == 'NULL') {
$conditions['city_id IS ?'] = NULL;
} else {
$conditions['city_id'] = $this->data['users']['city_id'];
}
}
//debug($this->data);
$options = array(
'limit' => 20,
'order' => 'User.lastname ASC',
'conditions' => $conditions);开发者_如何学JAVA
$this->paginate = $options;
$users = $this->paginate('User');
As you can see, I use the paginate()
function within the controller. I still don't understand why it's working for the gender filter and not the rest
Cheers,
Nicolas.Your problem is not in the controller, while in the helper. When you pass the variable for the first time, it's working, because there is posted variable, but the pagination doesn't handle these variables unless you pass them to the pagination helper.
Read this article and in my opinion it's best to pass the gender, and city via _GET.
精彩评论