You are here

function disable_breadcrumbs_node_load in Disable breadcrumbs 7

Implements hook_node_load().

File

./disable_breadcrumbs.module, line 111
Disable breadcrumbs

Code

function disable_breadcrumbs_node_load($nodes) {
  $disable_breadcrumbs_all = variable_get('disable_breadcrumbs_all', NULL);

  // Return if all breadcrumbs are disabled.
  if ($disable_breadcrumbs_all) {
    return;
  }
  $enabled_content_types = variable_get('disable_breadcrumbs_node_types', array());
  $all_breadcrumbs_disabled_content_types = variable_get('disable_breadcrumbs_node_types_all', array());
  foreach ($nodes as $node) {

    //Just in case node hasn't been created - will have no nid.
    if (!isset($node->nid)) {
      continue;
    }

    // Check if node type is enabled.
    if (in_array($node->type, $enabled_content_types, TRUE)) {

      // Check to see if node has been checked.
      if (_disable_breadcrumbs_node_query($node->nid)) {
        $node->disable_breadcrumb = 1;
      }
      else {
        $node->disable_breadcrumb = 0;
      }
    }
    elseif (in_array($node->type, $all_breadcrumbs_disabled_content_types, TRUE)) {
      $node->disable_breadcrumb = TRUE;
    }
    else {
      $node->disable_breadcrumb = FALSE;
    }
  }
  return $nodes;
}