You are here

function content_handler_field::render in Content Construction Kit (CCK) 6.2

Same name and namespace in other branches
  1. 6.3 includes/views/handlers/content_handler_field.inc \content_handler_field::render()
1 call to content_handler_field::render()
content_handler_field_multiple::render in includes/views/handlers/content_handler_field_multiple.inc
1 method overrides content_handler_field::render()
content_handler_field_multiple::render in includes/views/handlers/content_handler_field_multiple.inc

File

includes/views/handlers/content_handler_field.inc, line 182
The subclass adds basic field and formatter info, for field-specific subclasses to use if they need to.

Class

content_handler_field
@file The subclass adds basic field and formatter info, for field-specific subclasses to use if they need to.

Code

function render($values) {

  // We're down to a single node here, so we can retrieve the actual field
  // definition for the node type being considered.
  $field = content_fields($this->content_field['field_name'], $values->{$this->aliases['type']});

  // If the field does not appear in the node type, then we have no value
  // to display, and can just return.
  if (empty($field)) {
    return '';
  }
  $options = $this->options;
  $db_info = content_database_info($field);

  // Build a pseudo-node from the retrieved values.
  $node = drupal_clone($values);
  $node->type = $values->{$this->aliases['type']};
  $node->nid = $values->{$this->aliases['nid']};
  $node->vid = $values->{$this->aliases['vid']};

  // Some formatters need to behave differently depending on the build_mode
  // (for instance: preview), so we provide one.
  $node->build_mode = NODE_BUILD_NORMAL;
  $item = array();
  foreach ($db_info['columns'] as $column => $attributes) {
    $item[$column] = $values->{$this->aliases[$attributes['column']]};
  }
  $item['#delta'] = $field['multiple'] ? $values->{$this->aliases['delta']} : 0;

  // Render items.
  $formatter_name = $options['format'];
  if ($formatter = _content_get_formatter($formatter_name, $field['type'])) {
    if (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE) {

      // Single-value formatter.
      $output = content_format($field, $item, $formatter_name, $node);
    }
    else {

      // Multiple values formatter - we actually have only one value to display.
      $output = content_format($field, array(
        $item,
      ), $formatter_name, $node);
    }
    return $this
      ->render_link($output, $values);
  }
  return '';
}