You are here

function themekey_taxonomy_vid2tid_and_parents in ThemeKey 6.3

Same name and namespace in other branches
  1. 6.4 modules/themekey.taxonomy.inc \themekey_taxonomy_vid2tid_and_parents()

ThemeKey mapping function to set a ThemeKey property's value (destination) with the aid of another ThemeKey property (source).

src: node:vid dst: taxonomy:tid_and_parents

Parameters

$node_vid: node version id

Return value

array of taxonomy term ids or NULL if no value could be mapped

1 string reference to 'themekey_taxonomy_vid2tid_and_parents'
themekey_taxonomy_themekey_properties in modules/themekey.taxonomy.inc
Implements hook_themekey_properties().

File

modules/themekey.taxonomy.inc, line 183
Provides some taxonomy stuff as ThemeKey properties.

Code

function themekey_taxonomy_vid2tid_and_parents($node_vid) {
  $node_tids = themekey_taxonomy_vid2tid($node_vid);
  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;
}