Saturday, April 27, 2013

Paginate search results

Hi people.
I'm new to cakephp and need your help. I have this search function in my
UsersController, so there's a problem with search result pagination. The
first page shows first five names properly, but next pages does not show
anything. I need that this session save all my users, then check and
basically read it in next pages.
so how it should be?
th error message

*Undefined index: pageCount [CORE\Cake\View\Helper\PaginatorHelper.php, line
702]*

and the
public function search() {

if (!empty($this -> data)) {
$keyword = $this -> data['User']['search'];
$this -> Session -> write('users', $keyword);

if ($this -> Session -> check('users')) {
$keyword = $this -> Session -> read('users');

} elseif (isset($keyword, $this -> data['User']['search'])) {
$this -> paginate = array('conditions' => array('OR' =>
array("User.first_name LIKE" => "$keyword%", "User.last_name LIKE" =>
"$keyword%")), 'limit' => 5);
$this -> set('users', $this -> paginate('User'));

}
}

pls helpp
Thanks in advance :)



--
View this message in context: http://cakephp.1045679.n5.nabble.com/Paginate-search-results-tp5714685.html
Sent from the CakePHP mailing list archive at Nabble.com.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: