function tripal_core_get_toc_overrides

2.x tripal_core.toc.inc tripal_core_get_toc_overrides($nid, $key, $node_type, $mode)
3.x tripal_core.toc.inc tripal_core_get_toc_overrides($nid, $key, $node_type, $mode)

Parameters

$build:

1 call to tripal_core_get_toc_overrides()
tripal_core_node_view_build_toc in tripal_core/includes/tripal_core.toc.inc
To be called by tripal_core_node_view_alter() to generate the TOC.

File

tripal_core/includes/tripal_core.toc.inc, line 596

Code

function tripal_core_get_toc_overrides($nid, $key, $node_type, $mode) {
  // Set override defaults
  $override_title = '';
  $override_weight = '';
  $override_hide = 0;

  if ($mode != "manage_type") {
    // First look to see if the node has customizations for this item.
    $toc_item_overrides = db_select('tripal_toc', 'tc')
      ->fields('tc', array('title', 'weight', 'hide'))
      ->condition('key', $key)
      ->condition('nid', $nid)
      ->execute()
      ->fetchObject();
    if ($toc_item_overrides) {
      $override_title = $toc_item_overrides->title;
      $override_weight = $toc_item_overrides->weight;
      $override_hide = $toc_item_overrides->hide;
      return array(
        'title' => $override_title,
        'weight' => $override_weight,
        'hide' => $override_hide,
      );
    }
  }

  // If there are no specific node customizations then look to see if there
  // are customizations for this content type.
  $toc_item_overrides = db_select('tripal_toc', 'tc')
    ->fields('tc', array('title', 'weight', 'hide'))
    ->condition('node_type', $node_type)
    ->condition('key', $key)
    ->isNull('nid')
    ->execute()
    ->fetchObject();
  if ($toc_item_overrides) {
    $override_title = $toc_item_overrides->title;
    $override_weight = $toc_item_overrides->weight;
    $override_hide = $toc_item_overrides->hide;
  }

  return array(
    'title' => $override_title,
    'weight' => $override_weight,
    'hide' => $override_hide,
  );

}