Instead of manually doing the implementation of the searching and filtering in your models, you may be interested in using the CakeDC Search plugin, a powerful and reusable way to implement database search in your application.
In this recipe, we'll see how easy it can be to include the plugin within an application and add some search power on the fly.
First, we'll need to download and install the CakeDC Search plugin. We'll use git modules for the setup, but if you're not using git, you can simply download the ZIP file and place the contents of the plugin in a folder named
app/Plugin/Search/, as shown in the following command:
$ git submodule add git://github.com/CakeDC/search.git app/Plugin/Search
After that, load the plugin in your
bootstrap.php file, which is located in
app/Config/, using the following code:
In this recipe, we're going to quickly build a search panel to filter our categories by their names (using
LIKE) and by the...