You are here

function themekey_taxonomy_vid2vid in ThemeKey 6.4

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

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

src: node:vid dst: taxonomy:vid

Parameters

$node_vid: node version id

Return value

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

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

File

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

Code

function themekey_taxonomy_vid2vid($node_vid) {
  $vid = array();

  // Use SQL instead taxonomy API because this code runs during hook_init() stage.
  // Using taxonomy API will require to load the node using node_load() which is not allowed in this stage.
  $result = db_query('SELECT td.vid FROM {term_data} td INNER JOIN {term_node} tn ON td.tid = tn.tid WHERE tn.vid = %d', $node_vid);
  while ($term = db_fetch_object($result)) {
    $vid[] = $term->vid;
  }
  return count($vid) ? $vid : NULL;
}