You are here

function node_breadcrumb_nodeapi in Node breadcrumb 6

File

./node_breadcrumb.module, line 17

Code

function node_breadcrumb_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  if ($op == 'view' && $page) {
    $db_rules = db_query("select * from {node_breadcrumb_rule} order by weight, rid");
    while ($rule = db_fetch_object($db_rules)) {

      // check node type
      if ($rule->node_type != '' && $node->type != $rule->node_type) {
        continue;
      }

      // check terms
      foreach (array(
        $rule->tid1,
        $rule->tid2,
      ) as $tid) {
        if ($tid > 0) {
          if (empty($node->taxonomy[$tid])) {
            continue 2;
          }
        }
        elseif ($tid < 0) {
          foreach ($node->taxonomy as $term) {
            if ($term->vid == -$tid) {
              continue 2;
            }
          }
          continue 2;
        }
      }

      // check php condition
      if ($rule->condition != '') {
        eval("\$condition={$rule->condition};");
        if (!$condition) {
          continue;
        }
      }

      // apply menu location
      _node_breadcrumb_set_location($rule->mid, "node/{$node->nid}", $node->title);
      break;
    }
    module_invoke_all("node_breadcrumb", $node);
  }
}