これがどのように行われたかに興味がある他の人のために、ここにコードがあります。フック ルートを下って、次のコードで「channel_entries_query_result」フックにバインドしました。
public function query_result_filtered($c, $res){
# maybe this can be done better? Grabs the tag data for this template call
$tags = $c->EE->TMPL->tag_data;
foreach($tags as $tag):
# We're only interested in exp:channel:entries
if($tag['class'] == 'channel' && $tag['method'] == 'entries'):
# We're only interested if the tag has a param of matching, e.g. {exp:channel:entries matching="field_1|field_2"}
if(isset($tag['params']['matching'])):
$res = $this->_parse_results($res, $tag['params']['matching']);
endif;
endif;
endforeach;
return $res;
}
private function _parse_results($res, $fields){
$ret = array();
$fields = explode('|', $fields);
//If we dont have multiple tags to match against, return the result set as is
if(!is_array($fields)):
return $res;
endif;
# Get the field id's and count how many fields we're checking against
$fields = $this->_get_field_ids($fields);
$field_count = count($fields);
foreach($res as $row):
# Value to match against (just use the first value)
$tomatch = $row[$fields[0]];
# Keep a count on how many matches, so we can check that they all match
$match = 0;
foreach($fields as $field):
# If the current field matches that of the first field then we have a match, increment the count
if($row[$field] == $tomatch):
$match++;
endif;
endforeach;
# If we have matched all fields then add this row to the returned array
if($match == $field_count):
$ret[] = $row;
endif;
endforeach;
return $ret;
}
private function _get_field_ids($fields){
$ret = array();
# Loop through the fields given and find their ID's (this could be better and check site id for multisite compatibility)
foreach($fields as $field):
$q = $this->EE->db->select('field_id')->where('field_name', $field)->get('exp_channel_fields');
# Create a nice name that we can use as an array key when we check each rows value
$ret[] = 'field_id_' . $q->row('field_id');
endforeach;
return $ret;
}
特にエレガントではありませんが、うまくいきました。他の誰かがより良い解決策を持っているなら、私はそれについて聞きたいです. ありがとう