Re: Suggestion: Custom paginate() method ...in a Behavior

2008-09-05 Thread fr3nch13

Overwrite the method in any class (controller or even appcontroller/
appmodel) that inherits the library's class (controller/model)

On Sep 5, 6:52 am, Jaime [EMAIL PROTECTED] wrote:
 It is possible to define custom paginate() and paginateCount() methods
 in a model.

 But sometimes many models can share that same pagination methods, and
 therefore they could be defined in a single behavior. However, the
 core paginate() method in Cake's  core (default) controller only calls
 the custom method when they are found in the model:

 // From /cake/libs/controller/controller.php, line 990:
 if (method_exists($object, 'paginate')) {
         $results = $object-paginate($conditions, $fields, $order, $limit,
 $page, $recursive);

 }

 A workaround for this is to set the custom paginate methods in the
 AppModel. However, it would be much nicer if the core paginate()
 method would search for custom methods both in the model AND in it's
 behavior.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Suggestion: Custom paginate() method ...in a Behavior

2008-09-05 Thread Jaime

Of course I can but, shouldn't be this in the core?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Suggestion: Custom paginate() method ...in a Behavior

2008-09-05 Thread Jaime

Another workaround for this:

class AppModel extends Model {

  function paginate($params) {
return $this-Behaviors-Mybehaviour-paginate($this, $params);
  }
  function paginateCount($conditions) {
return $this-Behaviors-Mybehaviour-paginateCount($this,
$conditions);
  }

}

I don't like it very much but, is there any cleaner solution?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---