You are here

function themekey_taxonomy_tid2tid_and_parents in ThemeKey 6.2

Same name and namespace in other branches
  1. 6.4 modules/themekey.taxonomy.inc \themekey_taxonomy_tid2tid_and_parents()
  2. 6.3 modules/themekey.taxonomy.inc \themekey_taxonomy_tid2tid_and_parents()
  3. 7.3 modules/themekey.taxonomy.inc \themekey_taxonomy_tid2tid_and_parents()
  4. 7 modules/themekey.taxonomy.inc \themekey_taxonomy_tid2tid_and_parents()
  5. 7.2 modules/themekey.taxonomy.inc \themekey_taxonomy_tid2tid_and_parents()

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

src: taxonomy:tid dst: taxonomy:tid_and_parents

Parameters

$tids: array of taxonomy term ids or a single term id

Return value

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

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

File

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

Code

function themekey_taxonomy_tid2tid_and_parents($tids) {
  $tids = is_array($tids) ? $tids : array(
    $tids,
  );
  foreach ($tids as $tid) {

    // note that taxonomy_get_parents_all() returns the term itself
    $parent_terms = taxonomy_get_parents_all($tid);
    $parents = array();
    foreach ($parent_terms as $parent_term) {
      $parents[] = $parent_term->tid;
    }
  }
  return count($parents) ? array_unique($parents) : NULL;
}