Help understanding filters, add_filter(), and how to perform advanced module search.
I'm having a hard time figuring out how to use add_filter() to return an advanced module's model records based on a search term. I looked at some of fuel's builtin modules but i still have some questions.
Let's say i want to search for an "article" that has the word 'test' in either the title or its content.
1) Where should i add these filters so that the returned results of find_all only include the search results? Inside the module itself or can i call the
function from a controller?
2) How should i apply these filters? I tried doing
$this->module_name->add_filters(array('title' => 'test', 'content' => 'test'))
but i still get ALL results in the following find_all()
I guess I need a simple example with a module being loaded and searched with a static term. I will have no problems adding the form handling to that then...
public $filters = array('title', 'content_filtered', 'fuel_users.first_name', 'fuel_users.last_name');
Additionally, there is a "filter_join" property that you can specify either "and" or "or" which by default is "or". This query is generated in the base_module_model.php list_items() method.
1) set in my model class
2) right before the find_all() method , i set UPDATE:
this works for list_items but not in my custom get_all() method that uses find_all(), - I'll go ahead and see how to add the filters to find_all()