You are here

function content_nodeapi in Content Construction Kit (CCK) 6.2

Same name and namespace in other branches
  1. 5 content.module \content_nodeapi()
  2. 6.3 content.module \content_nodeapi()
  3. 6 content.module \content_nodeapi()

Implementation of hook_nodeapi().

File

./content.module, line 416
Allows administrators to associate custom fields to content types.

Code

function content_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {

  // Prevent against invalid 'nodes' built by broken 3rd party code.
  if (isset($node->type)) {
    $type = content_types($node->type);

    // Save cycles if the type has no CCK fields.
    if (!empty($type['fields'])) {
      $callback = 'content_' . str_replace(' ', '_', $op);
      if (function_exists($callback)) {
        $callback($node, $a3, $a4);
      }
    }

    // Special case for 'view' op, we want to adjust weights of non-cck fields
    // even if there are no actual fields for this type.
    if ($op == 'view') {
      $node->content['#pre_render'][] = 'content_alter_extra_weights';
      $node->content['#content_extra_fields'] = $type['extra'];
    }
  }
}