Thanks. It really worked.
It also reduced my number of lines of code
Thank you,
Sanjeev
On Nov 12, 5:45 pm, grigri <[EMAIL PROTECTED]> wrote:
> In that case use the 'extras' array:
>
> controller that uses the limit:
>
> var $paginate = array(
> 'limit' => 10,
> 'max_records' => 50 // Note this extra value
> );
>
> model (or even in AppModel; will work fine)
>
> class Something extends AppModel {
> // ...
>
> function paginateCount($conditions, $recursive, $extra) {
> $params = array_merge(compact('conditions', 'recursive'), $extra);
> $count = $this->find('count', $params);
> if (!empty($extra['max_records']) && $count > $extra
> ['max_records']) {
> $count = $extra['max_records'];
> }
> return $count;
> }
>
> }
>
> So if you set the key then it will limit the results, if you don't it
> won't. Simple.
>
> hth
> grigri
>
> On Nov 12, 11:34 am, snsanju <[EMAIL PROTECTED]> wrote:
>
> > Thanks grigri. I have already thought about it.
> > I want 50 records only on home page but not at other places.
> > if i give the condition (paginateCount) as you suggested, then will it
> > not limit the records to 50 for other request as well?
>
> > I want this page count limit for one request only.
>
> > Thank you,
> > Sanjeev
>
> > On Nov 12, 3:41 pm, grigri <[EMAIL PROTECTED]> wrote:
>
> > > I don't think there's an option to limit the total number of records,
> > > but you can achieve this quite easily by overiding the paginateCount
> > > function in the model:
>
> > > class Something extends AppModel {
> > > // ...
>
> > > function paginateCount($conditions, $recursive, $extra) {
> > > $params = array_merge(compact('conditions', 'recursive'), $extra);
> > > $count = $this->find('count', $params);
> > > if ($count > 50) {
> > > $count = 50;
> > > }
> > > return $count;
> > > }
>
> > > }
>
> > > hth
> > > grigri
>
> > > On Nov 12, 10:15 am, snsanju <[EMAIL PROTECTED]> wrote:
>
> > > > hi, I have 500 records or even more.
> > > > on my home page i want to display only 10 records using pagination
>
> > > > till here its fine. i am getting as expected. But my requirement is
> > > > something different.
>
> > > > I want only pagination for first 5 pages (means only for latest 50
> > > > records i.e, 5x10 = 50). i mean only 5 maximum pages.
> > > > is there any options in pagination function to limit the number of
> > > > pages like limiting number of records.
> > > > I feel, in one of previous version there was a option called maxpages
> > > > (not sure).
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---