Its a bit of collaboration
I see who channel entries tag Search:FIELD=”=value” don’t work for checkbox or multi-select fields.
Because the value of entry need be exactly same searched.
but checkbox can storage many values.
so i needed search a single value like:
needle: 1
haystack: 0|2|3|10|11if I do simple
search:field=“1”
its founded. But its not true. because “1” not is a single value.
===
another situation with different haystack and different syntax
needle: 1
haystack: 0|1|2|3|10|11if I do
search:field=”=1”
its not founded…
Because this, I add a new appropriated method to search it.
We had to add the code to the expressionengine/modules/mod.channel.php
on line 3656
//use search:field="|value" to search values on checkbox or mult-select fields
if( ! empty($this->EE->TMPL->search_fields) ){
foreach($this->EE->TMPL->search_fields as $field_name => $terms){
if(isset($this->cfields[$this->EE->config->item('site_id')][$field_name])){
if(strncmp($terms, '|',1) == 0){
$query_edit = array();
$terms = substr($terms, 1);
$field_id = 'field_id_'.$this->cfields[$this->EE->config->item('site_id')][$field_name];
foreach($query_result as $result){
if( is_numeric(array_search( $terms, explode("|",$result[$field_id]) ) ) ){
$query_edit[] = $result;
}
}
$query_result = $query_edit;
unset($query_edit);
}
}
}
}The syntax tag to use this is:
search:field=”|value”
Tests on we case:
search:regioes=”|1”
results:
field value 5|10 needle 1 not found!
Array
(
[0] => 5
[1] => 10
)
field value 1|5|6|7|8|9|10 needle 1 found!
Array
(
[0] => 1
[1] => 5
[2] => 6
[3] => 7
[4] => 8
[5] => 9
[6] => 10
)I hope helped some lives
And sorry for bad english