You are here

function taxonomy_breadcrumb_node_view in Taxonomy Breadcrumb 7

Implements hook_node_view().

File

./taxonomy_breadcrumb.module, line 54
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_node_view($node, $view_mode = 'full') {
  if ($view_mode == 'full' && !drupal_is_front_page()) {

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

    // 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)) {
      $breadcrumb = array();

      // Only take over breadcrumbs if terms are associated with the node.
      if ($tid = _taxonomy_breadcrumb_node_get_lightest_term($node->nid)) {

        // Generate the breadcrumb using the lightest vocabulary/term found.
        $breadcrumb = _taxonomy_breadcrumb_generate_breadcrumb($tid);
        if (variable_get('taxonomy_breadcrumb_page_title', FALSE)) {
          $breadcrumb[] = check_plain($node->title);
        }
        drupal_set_breadcrumb($breadcrumb);
      }
    }
  }
}