Re: Need some help with pagination in 1.2

2007-03-20 Thread barduck


No one? Nothing?

Ok. Anyway, for lack of better advice I decided that I will just copy
the paginate() method from the base Controller to my controller,
remove the stuff I don't need and add my own logic in between to
validate and replace the parameters.

makes sense?




On Mar 18, 12:44 pm, "barduck" <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I need some help and advice with implementing pagination in 1.2 .
>
> I got the basic functionality working which means I have paginate()
> return the correct count of items of the first page and if change the
> URL to pass different page # and limit #, the page behaves as
> expected.
>
> What I am not sure about is how to get more control over the
> pagination behavior and make it do exactly what I want. Looking at the
> source code it seems like paginate() is taking its parameters from the
> URL in is various forms (params, URL and passedArgs) and it overrides
> anything else I can set (well, there is whitelist but I am not sure
> how to use it exactly and couldn't make it to work).
>
> I am looking for the proper way to do the following:
>
> 1. Validate the parameters passed to paginate(). For example having a
> max and min values that the "limit" parameter can have (to prevent
> just calling my page with huge limit numbers) or to prevent some field
> names as entries for being sorted by (currently, everything passed in
> the URL goes).
>
> 2. Gracefully ignore any fields that are passed as sort parameter and
> don't actually exists. So if a user enters some non existing field
> name in the URL, the page just ignores it and sorts the data by the
> default field instead of displaying an ugly error.
>
> 3. Have aliases for some fields to be used with the sort parameters.
> So if I need to sort by a field that is nested a level or two deep
> inside the model, I can just use something like "sort:alias_name"
> instead of writing the entire hierarchy for the required field.
>
> Where is the proper place to hook the above? What is the best way to
> achieve it and keep everything clean?
>
> On a related note, what could be the reason for $paginator->next('>>',
> null, null, null) not returning the correct URL for the next page? It
> just returns the same URL the page is on, without any parameters. Do I
> need to pass anything special to it?
>
> Thanks in advance.


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



Need some help with pagination in 1.2

2007-03-18 Thread barduck

Hi all,

I need some help and advice with implementing pagination in 1.2 .

I got the basic functionality working which means I have paginate()
return the correct count of items of the first page and if change the
URL to pass different page # and limit #, the page behaves as
expected.

What I am not sure about is how to get more control over the
pagination behavior and make it do exactly what I want. Looking at the
source code it seems like paginate() is taking its parameters from the
URL in is various forms (params, URL and passedArgs) and it overrides
anything else I can set (well, there is whitelist but I am not sure
how to use it exactly and couldn't make it to work).

I am looking for the proper way to do the following:

1. Validate the parameters passed to paginate(). For example having a
max and min values that the "limit" parameter can have (to prevent
just calling my page with huge limit numbers) or to prevent some field
names as entries for being sorted by (currently, everything passed in
the URL goes).

2. Gracefully ignore any fields that are passed as sort parameter and
don't actually exists. So if a user enters some non existing field
name in the URL, the page just ignores it and sorts the data by the
default field instead of displaying an ugly error.

3. Have aliases for some fields to be used with the sort parameters.
So if I need to sort by a field that is nested a level or two deep
inside the model, I can just use something like "sort:alias_name"
instead of writing the entire hierarchy for the required field.


Where is the proper place to hook the above? What is the best way to
achieve it and keep everything clean?


On a related note, what could be the reason for $paginator->next('>>',
null, null, null) not returning the correct URL for the next page? It
just returns the same URL the page is on, without any parameters. Do I
need to pass anything special to it?

Thanks in advance.


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