Tuesday, June 30, 2009

Re: Pagination not respecting page numbers

Heya,

Ahh I figured out what the problem was...

I had

$data = $this->paginate('Property', $conditions, $fields, $theorder,
$resultsperpage, $page);

but the paginate function doesn't take those parameters...

I had to use:

$this->paginate = array(
'limit' => $resultsperpage,
'order' => $theorder,
'fields' => $fields,
'page' => $page
);

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

oops!

On Wed, Jun 24, 2009 at 9:16 PM, schneimi<michael.schneidt@arcor.de> wrote:
>
> Hi,
>
> I am not sure about your problem, but I also use named params and can
> tell you how to pass them to the next pages without a session
> workaround.
>
> Well, but you can also do it with the session, the only thing you have
> to do, is to pass the named parameters to the pagination functions
> with the "url" option.
>
> For not using the session, you can define the options in the
> controller with the incoming params like this
>
>    $this->set('paginationOptions', array('url' => array('title:'.
> $this->params['named']['title'],
>
> 'year:'.$this->params['named']['year'])));
>
> and then pass the options to the pagination functions that you use in
> the view, like $paginator->numbers($options),...
>
> Hope this helps,
>
> Michael
>
> On 24 Jun., 20:44, Bryan Paddock <bryanpadd...@gmail.com> wrote:
>> Hey all,
>>
>> I was using the paginator and it was working pretty well for me when I
>> was using all the search criteria as named url parameters. I
>> discovered that the paginator didn't send the parameters to the next
>> pages so implemented sessions to store the criteria.
>>
>> The arrays I create from the session (critera/order) generate fine and
>> the page number variable I take from the named url parameter.
>>
>> examples of values follow....
>>
>> $conditions = Array
>> (
>>     [sale] => 1
>> )
>>
>> $theorder = Array
>> (
>>     [created_date_time] => DESC
>> )
>>
>> $resultsperpage = 10;
>>
>> $page = 1; // or 2, 3, etc
>>
>> My paginator call is:
>>
>> $data = $this->paginate('Property', $conditions, $theorder,
>> $resultsperpage, $page);
>>
>> For some reason it respects the conditions, order and results per page
>> but NOT the page number. Anyone have any ideas why? I test the value
>> of the $page variable and it does correctly change but the data
>> received from the model remains the same.
>>
>> Am I doing something wrong here? I can't figure out what's going on....
>>
>> thanks!
>> bryan
> >
>

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

No comments: