You are here

function taxonomy_breadcrumb_nodeapi in Taxonomy Breadcrumb 6

Same name and namespace in other branches
  1. 5 taxonomy_breadcrumb.module \taxonomy_breadcrumb_nodeapi()

Implementation of hook_nodeapi().

File

./taxonomy_breadcrumb.module, line 61
The taxonomy_breadcrumb module generates taxonomy based breadcrumbs on node pages and taxonomy/term pages. The breadcrumb trail takes on the form: [HOME] >> [VOCABULARY] >> TERM >> [TERM] ...

Code

function taxonomy_breadcrumb_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {

  // If we are on a page view (not just a teaser), set the breadcrumb.
  // $a4 contains TRUE if we are on a page view.
  if ($op == 'view' && $a4 && !drupal_is_front_page()) {

    // Include the .inc file with all helper functions
    include_once drupal_get_path('module', 'taxonomy_breadcrumb') . '/taxonomy_breadcrumb.inc';

    // See if the node type of the current node is part of the node types listed on the advanced settings page.
    $array_of_types = array_filter((array) variable_get('taxonomy_breadcrumb_node_types', TAXONOMY_BREADCRUMB_NODE_TYPES_DEFAULT));
    $in_list = in_array($node->type, $array_of_types);

    // if the node type IS IN     the node types list and the list IS     inclusive OR
    // if the node type IS NOT IN the node types list and the list IS NOT inclusive (e.g. exclusive)
    // THEN modify the breadcrumb trail.
    if ($in_list == variable_get('taxonomy_breadcrumb_include_nodes', 0)) {

      // Extract lightest term from lightest vocabulary assosciated with node.
      $term = _taxonomy_breadcrumb_node_get_lightest_term($node);
      $breadcrumb = _taxonomy_breadcrumb_generate_breadcrumb($term->tid);
      if (variable_get('taxonomy_breadcrumb_include_node_title', FALSE)) {
        $breadcrumb[] = check_plain($node->title);
      }
      drupal_set_breadcrumb($breadcrumb);
    }
  }
}