You are here

function _nd_nodeapi in Display Suite 6.3

Helper function to alter node properties

Parameters

stdClass $node The complete node object.:

1 call to _nd_nodeapi()
nd_nodeapi in modules/nd/nd.module
Implementation of hook_nodeapi().

File

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

Code

function _nd_nodeapi(&$node) {

  // Attach a display to the node object
  ds_attach_display($node);
  $node->ds
    ->prepare($node);

  // Build fields and regions.

  //ds_build_fields_and_regions($node, 'nd');

  // Special support for RSS.
  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;
      }
      $node->content[$field]['#weight'] = $node->ds_fields[$field]['weight'];
      unset($node->ds_fields[$field]);
    }
    foreach ($node->ds_fields as $key => $field) {
      $render_key = $key . '_rendered';
      $node->content[$key]['#value'] = theme('ds_field', $node->{$render_key}, $node->ds_fields[$key]);
      $node->content['#content_extra_fields'][$key]['weight'] = $node->ds_fields[$key]['weight'];
    }

    // 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'];
  }
  if (function_exists('rules_invoke_event')) {
    rules_invoke_event('nd_node_is_build', array(
      'node' => &$node,
    ));
  }
}