This is because the search Term is not available to the controller
function when you go to 2nd page and it just displays all the results.
Set the debug mode to 2 and check the queries generated on both the
pages. This will help you analyse the issue.
Try the following line of code in views
$this->Paginator->options(array('url' => $this->passedArgs));
Check following for more details:
http://book.cakephp.org/view/1233/Pagination-in-Views
Thanks,
Hunny.
On Apr 1, 2:13 am, Spetz83 <[email protected]> wrote:
> Hi all,
>
> I am having an issue with the cake paginator. When a user comes to my
> site and does a search I am using the paginator for the search
> results. My code looks like this:
>
> function search() {
>
> $term= '';
> if(!empty($this->data)) {
> $term = $this->data['Search']['search_input'];
> }
>
> //$this->Product->recursive = 0;
> $search = array('Product.name LIKE'=>"%$term%",
> 'Product.description LIKE'=>"%$term%",'Provider.name LIKE'=>"%$term%",
> 'Provider.description LIKE'=>"%$term%");
> $this->paginate = array('conditions'=>array('provider_id !
> ='=>0, 'Product.published'=>true, 'Product.disabled'=>null,
> 'Provider.published'=>true, 'Provider.active'=>true,
> 'Provider.suspend'=>false, 'OR'=>$search), 'limit'=>25);
> $products = $this->paginate('Product');
> $title_for_layout = 'Search Results';
> $this->set(compact('products', 'title_for_layout'));
>
> }
>
> This method does return values, and the paginator does it's job.
> However, when the view displays the paginated results for the first
> time it says something like "Displaying page 1 of 7". When I click on
> page 2, the counter jumps to saying "Displaying page 1 of 10". My
> View code for the counter is below:
>
> <p style="float:right;">
> <?php
> echo $this->Paginator->counter(array(
> 'format' => __('Page %page% of %pages%, showing %current%
> records out of %count% total, starting on record %start%, ending on
> %end%', true)
> ));
> ?>
> </p>
> <div class="paging" style="float:right;">
> <?php echo $this->Paginator->first('<< '.__('first',
> true), array(), null, array('class'=>'disabled')); ?>
> <?php echo $this->Paginator->prev('< ' . __('previous',
> true), array(), null, array('class'=>'disabled'));?>|
> <?php echo $this->Paginator->numbers();?>|
> <?php echo $this->Paginator->next(__('next', true) . ' >',
> array(), null, array('class' => 'disabled'));?>
> <?php echo $this->Paginator->last(__('last', true).' >>',
> array(), null, array('class'=>'disabled')); ?>
> </div>
>
> I am using the paginator in other places of my site and I have not had
> this issue. Only with this specific view.
>
> Anyone else ever run into this?
>
> Thanks
>
> Tom
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php