function other_view_filter_handler_filter_view::query in OtherView Filter 7
Add this filter to the query.
Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.
Overrides views_handler_filter_in_operator::query
File
- ./
other_view_filter_handler_filter_view.inc, line 148 - Definition of views_handler_filter_entity_other_view filter.
Class
- other_view_filter_handler_filter_view
- Filter class which allows to filter by certain bundles of an entity.
Code
function query() {
$this
->ensure_my_table();
// Figure out what this entity id is called (eg. nid, uid, etc.)
$entity_info = entity_get_info($this->entity_type);
$id_key = $entity_info['entity keys']['id'];
$ids = array();
foreach ($this->value as $value) {
list($name, $display) = explode(':', $value, 2);
if ($name && $display) {
// Get the results of the specified view/display combo.
$results = views_get_view_result($name, $display);
foreach ($results as $result) {
$ids[$result->{$id_key}] = $result->{$id_key};
}
}
}
// Apply filter if selected views return some results.
if ($ids) {
$ids = array_values($ids);
$this->query
->add_where($this->options['group'], $this->table_alias . '.' . $id_key, $ids, $this->operator);
}
elseif ($this->operator === 'in') {
$this->query
->add_where($this->options['group'], 1, 2, '=');
}
}