You are here

function nd_nodeapi in Display Suite 6.3

Implementation of hook_nodeapi().

File

modules/nd/nd.module, line 112
Node displays.

Code

function nd_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  switch ($op) {

    // Add has body property.
    case 'load':
      $node->has_body = node_get_types('type', $node->type)->has_body;
      break;

    // Determine build mode.
    case 'view':
      if ($node->build_mode == NODE_BUILD_RSS) {

        // For the RSS build mode, we need to manipulate right now.
        _nd_nodeapi($node);
      }
      elseif ($node->build_mode == NODE_BUILD_PREVIEW) {
        $node->build_mode = $teaser ? 'teaser' : 'full';

        // Prepare taxonomy
        if (isset($node->taxonomy)) {
          foreach ($node->taxonomy as $tid => $term) {
            if (is_int($tid)) {
              $node->taxonomy[$tid] = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid));
            }
          }
        }
      }
      elseif ($node->build_mode === NODE_BUILD_NORMAL) {
        $build_mode = $teaser ? 'teaser' : 'full';
        $node->build_mode = $build_mode;
      }
      $node->has_body = node_get_types('type', $node->type)->has_body;
      if ($node->has_body == 1 && strlen($node->body) == 0) {
        $node->has_empty_body = 1;
      }
      drupal_alter('nd_build', $node);
      break;

    // Alter the node object for viewing.
    case 'alter':

      // We ignore the RSS build mode, which is handled in the view operation.
      if ($node->build_mode == NODE_BUILD_RSS) {
        return;
      }
      _nd_nodeapi($node);
      break;
  }
}