function themekey_taxonomy_nid2tid_and_parents in ThemeKey 6.2
ThemeKey mapping function to set a ThemeKey property's value (destination) with the aid of another ThemeKey property (source).
src: node:nid dst: taxonomy:tid_and_parents
Parameters
$nid: node id
Return value
array of taxonomy term ids or NULL if no value could be mapped
1 string reference to 'themekey_taxonomy_nid2tid_and_parents'
- themekey_taxonomy_themekey_properties in modules/
themekey.taxonomy.inc - Implements hook_themekey_properties().
File
- modules/
themekey.taxonomy.inc, line 180 - Provides some taxonomy stuff as ThemeKey properties.
Code
function themekey_taxonomy_nid2tid_and_parents($nid) {
$node_tids = themekey_taxonomy_nid2tid($nid);
if (!is_array($node_tids)) {
return FALSE;
}
$tids = $node_tids;
foreach ($node_tids as $tid) {
$parent_terms = taxonomy_get_parents_all($tid);
foreach ($parent_terms as $parent_term) {
$tids[] = $parent_term->tid;
}
}
return count($tids) ? array_unique($tids) : NULL;
}