开发者

Including search term in paging in CakePHP

开发者 https://www.devze.com 2023-01-31 03:33 出处:网络
Been pulling my hair out for about an hour now. How can I keep the search term for a paginated result set in the links (开发者_JAVA技巧like page numbers) etc

Been pulling my hair out for about an hour now. How can I keep the search term for a paginated result set in the links (开发者_JAVA技巧like page numbers) etc

Here is the code that creates the pagination (no other pagination related code anywhere else)

   $this->paginate = array (
   'conditions' => array('status ' => '0', 'OR' => array ( 'country LIKE' => $_GET['search'],  'administrative_area_level_1 LIKE' => $_GET['search'],  'locality LIKE' => $_GET['search'],  'sublocality_level_1 LIKE' => $_GET['search'],  'name LIKE' => '%' . $_GET['search'] .'%'  )) );

$data = $this->paginate('Segment');

However, the GET variable is not included in any of the paging links so when I click one the search term disappears.

The URL where the above code lives is: http://dev.cyclistsroadmap.com/main/segmentsearch


Try this in the view before the page numbers or next-previous links

    $paginator->options(
       array('url' => array('controller' => 'competitions','action' => 'competitionList','?'=>'search='.$_GET['search'])
    );

echo $paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
                        echo $page_no;
                        echo $paginator->next(' Next >>', null, null, array('class' => 'disabled'));
0

精彩评论

暂无评论...
验证码 换一张
取 消