You are here

function hs_content_taxonomy_hierarchical_select_lineage in Hierarchical Select 5.3

Same name and namespace in other branches
  1. 6.3 modules/hs_content_taxonomy.module \hs_content_taxonomy_hierarchical_select_lineage()

Implementation of hook_hierarchical_select_lineage().

1 call to hs_content_taxonomy_hierarchical_select_lineage()
hs_content_taxonomy_views_hierarchical_select_lineage in modules/hs_content_taxonomy_views.module
Implementation of hook_hierarchical_select_lineage().

File

modules/hs_content_taxonomy.module, line 467
Implementation of the Hierarchical Select API for the Content Taxonomy module.

Code

function hs_content_taxonomy_hierarchical_select_lineage($item, $params) {
  $lineage = hs_taxonomy_hierarchical_select_lineage($item, $params);

  // If there is NO root term, then the tid parameter is set to 0. In that
  // case, there is no need to remove any of the terms before the root term,
  // because there won't be any.
  if ($params['tid'] != 0) {

    // TRICKY: When the root term has been *changed* over time, it *might* not
    // be in the lineage, because the lineage. This means the lineage is not
    // inside the tree below the defined root term. So we have to reset the
    // lineage.
    if (!in_array($params['tid'], $lineage)) {
      $lineage = array();
    }
    else {

      // Remove all terms before the root term and then the root term itself, too.
      while (count($lineage) && $lineage[0] != $params['tid']) {
        array_shift($lineage);
      }
      array_shift($lineage);
    }
  }
  return $lineage;
}