Skip to content

Instantly share code, notes, and snippets.

@Cyberschorsch
Last active December 15, 2015 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cyberschorsch/5264117 to your computer and use it in GitHub Desktop.
Save Cyberschorsch/5264117 to your computer and use it in GitHub Desktop.
Helper function for the module file
<?php
/**
* Helper to filter tids on given vocabularies.
*
* @param array $tids
* array of term ids
* @param array $vocabularies
* array of vocabulary machine names
*
* @return array
* array of terms that live in one of the given vocabularies.
*/
function _views_flag_context_filter_tids_on_vocabularies($tids, $vocabularies) {
$query = db_select('taxonomy_term_data', 't')
->fields('t', array('tid'))
->condition('t.tid', $tids);
$query->innerJoin('taxonomy_vocabulary', 'v', 't.vid = v.vid');
$query->condition('v.machine_name', $vocabularies);
return $query->execute()->fetchCol();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment