{"id":16191320,"url":"https://github.com/dogmatic69/cakephp-sifter","last_synced_at":"2025-04-07T14:46:28.044Z","repository":{"id":14182534,"uuid":"16888770","full_name":"dogmatic69/cakephp-sifter","owner":"dogmatic69","description":"A plugin for sifting / filtering and searching model data","archived":false,"fork":false,"pushed_at":"2023-12-15T14:46:08.000Z","size":45,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-13T17:17:57.060Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dogmatic69.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.markdown","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-02-16T16:37:50.000Z","updated_at":"2014-02-17T23:41:21.000Z","dependencies_parsed_at":"2023-12-15T15:55:01.652Z","dependency_job_id":null,"html_url":"https://github.com/dogmatic69/cakephp-sifter","commit_stats":{"total_commits":44,"total_committers":1,"mean_commits":44.0,"dds":0.0,"last_synced_commit":"5ffbe275cd6dec138978032e8a5d13b9a3a15698"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogmatic69%2Fcakephp-sifter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogmatic69%2Fcakephp-sifter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogmatic69%2Fcakephp-sifter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogmatic69%2Fcakephp-sifter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dogmatic69","download_url":"https://codeload.github.com/dogmatic69/cakephp-sifter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247675618,"owners_count":20977376,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T07:45:50.218Z","updated_at":"2025-04-07T14:46:28.019Z","avatar_url":"https://github.com/dogmatic69.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/dogmatic69/cakephp-sifter.png?branch=master)](https://travis-ci.org/dogmatic69/cakephp-sifter)\n[![Coverage Status](https://coveralls.io/repos/dogmatic69/cakephp-sifter/badge.png)](https://coveralls.io/r/dogmatic69/cakephp-sifter)\n\n## Sifter\n\nSifter is a CakePHP plugin that makes searching and filtering data simple. It can also be configured to change how it searches.\n\nAll configuration is done in the model, which means there is no need to mess about with forms, redirects or any other code. A component interacts with request data and does various things depening on the data found in the request.\n\nMain Features:\n\n- Automatic form generation based on the configuration in the model / behavior config. (using included element)\n- Field type introspection for best input type\n- Automatic ajax autocomplete on all text inputs (requires jQuery to be included)\n- Automatic select dropdown for foreign key fields (including deep relations, with customisable find method setting)\n- Automatic pagination modification so it can be dropped in with minimal code changes, can also be used with normal finds or manually\n- Post -\u003e Redirect -\u003e Get so searches are indexable, linkable\n- Security - Will only search configured fields in configured actions, additional fields are simply ignored\n- Deep relation search, especially with custom finds doing the search it is possible to control all your joins and additional search requirements\n\n\nThe plugin is made up of the following main sections:\n\n### Behavior\n\nThe behavior does a number of things:\n- Figure out the form inputs based on the field schema\n- Find and call custom find methods in the model for fetching data\n- Configure what is searched and where\n\n### Component\n- catch requests and either redirect POST -\u003e GET or fetch data for ajax autocomplete\n- fetch and set data for view variables to populate selects in the search form\n- filter GET params and modify / return find conditions\n\n### Helper / element\n\nThis is the frontend to the Sifter plugin. This is totaly optional but should cover most usage cases. If you are not going to use the included element for the search form you should at least look at if for ideas as to what is required to make the search work.\n\n- Element: Search form default based on configured model and settings\n- Helper: Convert behavior settings into Form inputs\n\n## Install\n\nInstall with git\n\n\tgit clone https://github.com/dogmatic69/cakephp-sifter Plugin/Sifter\n\nInstall as a submodule\n\n\tgit submodule add https://github.com/dogmatic69/cakephp-sifter Plugin/Sifter\n\nInstall with composer (comming soon)\n\n\tcomposer.phar require dogmatic69/cakephp-sifter\n\n## Basic usage\n\nAttach the behavior to the model you would like to sift. This can be done in the actsAs property or dynamically, see the CakePHP docs for more details.\n\n\tclass MyModel extends AppModel {\n\t\tpublic $actsAs = array(\n\t\t\t... other behaviors\n\t\t\t'Sifter.Sifter' =\u003e array(\n\t\t\t\t'fields' =\u003e array(\n\t\t\t\t\t'MyModel.field_1' =\u003e array(\n\t\t\t\t\t\t'input' =\u003e array(\n\t\t\t\t\t\t\t'placeholder' =\u003e 'Customize your form with ease',\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\t'MyOtherModel.field_2', \n\t\t\t\t\t'field_3', // \u003c- will automatically use the current model alias\n\t\t\t\t)\n\t\t\t),\n\t\t);\n\n\t\t// code\n\t}\n\nOnce its attached to the model, you need to attach the component to the controller so that it can catch and deal with sifter requests. Again see the CakePHP docs for specifics\n\nclass MyController extends AppController {\n\t\n\tpublic $components = array(\n\t\t...,\n\t\t'Sifter.Sifter',\n\t);\n\n\t// code\n}\n\nFinally you need to have a form so that users will be able to input the serch requirements. There is an included element which will build a generic search form based on the inputs that have been configured. Alternativly you could use the form helper to build your own.\n\n\techo $this-\u003eelement('Sifter.sift');\n\nThat is it, now when you visit the page you should see a search form. Submitting data on in the form will do a PRG to to a URL containing all your params. If you are using pagination these will be included already in the `PaginatorComponent::$settings` property. If you are using a normal find on the page you can use the `SifterComponent::sift()` method to fetch the query conditions.\n\nIn a controller method:\n\n\t$conditions = $this-\u003eSifter-\u003esift($this);\n\tpr($conditions);\n\n\t// output\n\tarray(\n\t\t'conditions' =\u003e array(\n\t\t\t'MyModel.field_1' =\u003e 'foobar',\n\t\t\t'MyOtherModel.field_2' =\u003e 'baz',\n\t\t\t...\n\t\t),\n\t\t'contain' =\u003e array(\n\t\t\t'MyOtherModel',\n\t\t)\n\t)\n\n## Contribute\n\nSubmit bugs / patches on github.com/dogmatic69/cakephp-sifter","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdogmatic69%2Fcakephp-sifter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdogmatic69%2Fcakephp-sifter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdogmatic69%2Fcakephp-sifter/lists"}