Last active
December 15, 2015 12:59
-
-
Save Cyberschorsch/5264117 to your computer and use it in GitHub Desktop.
Helper function for the module file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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