You are here

function nd_nodeapi in Node displays 6

Same name and namespace in other branches
  1. 6.3 nd.module \nd_nodeapi()
  2. 6.2 nd.module \nd_nodeapi()

Implementation of hook_nodeapi().

File

./nd.module, line 38
Main node displays file.

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 == TRUE ? 'teaser' : 'full';
        $node->has_body = node_get_types('type', $node->type)->has_body;
      }
      elseif ($node->build_mode === NODE_BUILD_NORMAL) {
        $build_mode = $page ? 'full' : 'teaser';
        $node->build_mode = $build_mode;
      }
      if ($node->build_mode == 'teaser' && $node->sticky == 1) {
        $node->build_mode = 'nd_sticky';
      }
      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;
  }
}