CakePHP Plugin - Create custom find types by just defining functions
Latest commit aecd4f6 Jun 5, 2009 Matt Curry fixed up readme
Failed to load latest commit information.
tests made into plugin Apr 30, 2009
vendors added pagination support Jun 6, 2009
README fixed up readme Jun 6, 2009


 * CakePHP plugin for create custom find types
 * Copyright (c) 2009 Matt Curry
 * Thanks to Daniel Salazar for the inspiration on pagination support
 * @author      Matt Curry <>
 * @license     MIT

/* Description */
A CakePHP plugin that allows for creating custom find types by simply adding a new method to the model.

/* Install */
1) Download the plugin to /app/plugin/find

2) Include the FindAppModel in your app_model.php
App::import('Vendor', 'Find.find_app_model');

3) Have your AppModel extend FindAppModel instead of Model
class AppModel extends FindAppModel {


/* Usage */
1) Call custom find types with the pattern:

2) In your model create functions that match the find type with "__find" prefixed and the find type CamelCased:
function __findCustomFindType($options) {
  //do find here

/* How To Paginate */
This is pretty simple thanks Daniel Salazar (
1) Add "paginate" => true to the $options array will return the $query array, which is suitable for using as your controllers $paginate parameter.  
   You probably want to merge that with the default controller pagination settings.
   $this->paginate = am($this->paginate, $this->Post->find('published', array('paginate' => true)));
   $this->set('posts', $this->paginate());

/* Why This Is A Vendor, Not A Model */
When doing App::import on a model Cake checks that the AppModel class already exists, otherwise it tries to import.  Since the AppModel is depended on the FindAppModel, it won't exist and will try to be included, leading to a infinite loop.