function content_content_field_content_type_render in Content Construction Kit (CCK) 6.2
Same name and namespace in other branches
- 6.3 includes/panels/content_types/content_field.inc \content_content_field_content_type_render()
Output function for the 'field' content type.
File
- includes/
panels/ content_types/ content_field.inc, line 85 - This file provides a CTools content type for fields.
Code
function content_content_field_content_type_render($subtype, $conf, $panel_args, $context) {
// Previous versions of CCK included the content type as part of the subtype.
// This allows those to continue to sort of work, at least during render.
if (strpos($subtype, ':') !== FALSE) {
list($content_type, $subtype) = explode(':', $subtype, 2);
}
if (is_array($context)) {
$context = array_pop($context);
}
// If we do not have a node, then we cannot generate output.
if (!isset($context->data)) {
return;
}
$node = drupal_clone($context->data);
// Extract the node type from the node in context, the field name from the
// panels content type subtype, and get the content field structure.
$field_name = $subtype;
$field = content_fields($field_name, $node->type);
// Get the formatter that was selected in the settings dialog.
$formatter = $conf['formatter'];
// Check view access to the field.
if (!content_access('view', $field, NULL, $node)) {
return;
}
// Force panel settings into the field's display settings.
$field['display_settings']['label']['format'] = $conf['label'] == 'normal' || !empty($conf['override_title']) ? 'hidden' : $conf['label'];
$field['display_settings']['full']['format'] = $formatter;
$node->build_mode = NODE_BUILD_NORMAL;
// TODO : allow panel-specific template suggestions for content-field.tpl.php ?
$output = content_view_field($field, $node);
$block = new stdClass();
$block->module = 'content';
$block->delta = $field_name;
if ($conf['label'] == 'normal') {
$block->title = t($field['widget']['label']);
}
$block->content = $output;
return $block;
}