function views_node_taxonomy_filter_handler_filter_tid::query in Views Node Taxonomy Filter 6
Same name and namespace in other branches
- 7 views_node_taxonomy_filter_handler_filter_tid.inc \views_node_taxonomy_filter_handler_filter_tid::query()
Modify the query appropriately.
File
Class
Code
function query() {
if (empty($this->value)) {
return;
}
$allowed_vocabs = $this->value;
if (arg(0) != 'node') {
return;
}
$nid = arg(1);
if (!is_numeric($nid)) {
return;
}
$node = node_load($nid);
$taxonomy = $node->taxonomy;
$terms = array();
if (sizeof($taxonomy) < 1) {
return;
}
foreach ($taxonomy as $term) {
if (in_array($term->vid, $allowed_vocabs) && $term->tid && is_numeric($term->tid)) {
//it's an allowed term
$terms[] = $term->tid;
}
}
if (sizeof($terms) < 1) {
return;
}
$tids = implode(',', $terms);
//$country_tids = '307,110';
$nid = $this->value;
$alias = $this->query
->ensure_table('term_node');
$this->query
->add_where($this->options['group'], "{$alias}.tid in (%s)", $tids);
}