You are here

function _nd_nodeapi in Node displays 7

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

Helper function to alter node properties

Parameters

stdClass $node The complete node object.:

1 call to _nd_nodeapi()
nd_node_view in ./nd.module
Implements hook_node_view().

File

./nd.module, line 168
Node displays.

Code

function _nd_nodeapi($node) {

  // Build fields and regions.
  ds_build_fields_and_regions($node, 'nd');
  if ($node->build_mode == NODE_BUILD_RSS && $node->render_by_ds == TRUE) {
    foreach (element_children($node->content) as $key => $field) {
      if (!isset($node->ds_fields[$field])) {
        $node->content[$field]['#access'] = FALSE;
      }
      elseif (isset($node->ds_fields[$field]) && $node->ds_fields[$field]['type'] == 'ds') {
        $key = $field . '_rendered';
        $node->content[$field]['#value'] = theme('ds_field', $node->{$key}, $node->ds_fields[$field]);
      }
    }

    // Body and title are tricky ones since their weights are set
    // in #content_extra_fields, so update the value there!
    $node->content['#content_extra_fields']['body_field']['weight'] = $node->content['body']['#weight'];
    $node->content['#content_extra_fields']['title']['weight'] = $node->content['title']['#weight'];
  }
}