You are here

function theme_nodereference_formatter_full_teaser in Content Construction Kit (CCK) 6.3

Same name and namespace in other branches
  1. 6 modules/nodereference/nodereference.module \theme_nodereference_formatter_full_teaser()
  2. 6.2 modules/nodereference/nodereference.module \theme_nodereference_formatter_full_teaser()

Proxy theme function for 'full' and 'teaser' nodereference field formatters.

1 string reference to 'theme_nodereference_formatter_full_teaser'
nodereference_theme in modules/nodereference/nodereference.module
Implementation of hook_theme().

File

modules/nodereference/nodereference.module, line 350
Defines a field type for referencing one node from another.

Code

function theme_nodereference_formatter_full_teaser($element) {
  static $recursion_queue = array();
  $output = '';
  if (!empty($element['#item']['safe']['nid'])) {
    $nid = $element['#item']['safe']['nid'];
    $node = $element['#node'];
    $field = content_fields($element['#field_name'], $element['#type_name']);

    // If no 'referencing node' is set, we are starting a new 'reference thread'
    if (!isset($node->referencing_node)) {
      $recursion_queue = array();
    }
    $recursion_queue[] = $node->nid;
    if (in_array($nid, $recursion_queue)) {

      // Prevent infinite recursion caused by reference cycles:
      // if the node has already been rendered earlier in this 'thread',
      // we fall back to 'default' (node title) formatter.
      return theme('nodereference_formatter_default', $element);
    }
    if ($referenced_node = node_load($nid)) {
      $referenced_node->referencing_node = $node;
      $referenced_node->referencing_field = $field;
      $output = node_view($referenced_node, $element['#formatter'] == 'teaser');
    }
  }
  return $output;
}