/ Published in: PHP
**Important: this snipplet has moved to Github.**
- [taxonomy_select_nodes with multiple terms, in Drupal 7](https://gist.github.com/1973248)
- [taxonomy_select_nodes with multiple terms, in Drupal 7](https://gist.github.com/1973248)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * In Drupal 6, `taxonomy_select_nodes` was able to filter by multiple terms, * but Drupal 7 accepts only one Term ID. */ if (variable_get('taxonomy_maintain_index_table', TRUE)){ switch($operator){ case 'or': break; case 'and': $i = 0; foreach ($tids as $tid){ if ($i == 0){ $tables = 't0.nid FROM {taxonomy_index} t0 '; $where = "t0.tid = $tid "; } else { $tables .= "LEFT JOIN {taxonomy_index} t$i ON (t$i.nid = t".($i - 1).'.nid) '; $where .= "AND t$i.tid = $tid "; } $i ++; } $query = "SELECT $tables WHERE $where ORDER BY t0.nid ASC"; break; } } return $nids; }