function _classified_taxonomy_node_get_terms_by_vocabulary in Classified Ads 7.3
Re-implement taxonomy_node_get_terms_by_vocabulary(), removed in Drupal 7.
Parameters
object $node: A Classified Ad node containing at least a nid field.
int $vid: The id of the vocabulary by which to filter terms.
Return value
array An array of taxonomy terms for the node, limited to the passed vocabulary.
See also
_classified_get_breadcrumb_by_node()
1 call to _classified_taxonomy_node_get_terms_by_vocabulary()
- _classified_get_breadcrumb_by_node in ./
classified.module - Build a breadcrumb trail for an a Classified Ad node.
File
- ./
classified.module, line 713 - A pure D7 classified ads module inspired by the ed_classified module.
Code
function _classified_taxonomy_node_get_terms_by_vocabulary($node, $vid) {
/** @var SelectQuery $q */
$q = db_select('taxonomy_index', 'ti')
->comment(__FUNCTION__);
$q
->join('taxonomy_term_data', 'td', 'ti.tid = td.tid');
$q
->join('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
$q
->fields('ti', array(
'tid',
))
->addTag('node_access')
->condition('ti.nid', $node->nid)
->condition('td.vid', $vid);
$term_ids = $q
->execute()
->fetchCol();
$terms = taxonomy_term_load_multiple($term_ids);
return $terms;
}