Index: content.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/content.module,v retrieving revision 1.56.2.3 diff -w -u -F^f -r1.56.2.3 content.module --- content.module 3 May 2006 12:56:52 -0000 1.56.2.3 +++ content.module 16 Jul 2006 11:59:14 -0000 @@ -303,8 +303,9 @@ function content_delete(&$node) { * Implementation of hook_view(). */ function content_view(&$node, $teaser = FALSE, $page = FALSE) { - $node->body = implode('', _content_field_invoke('view', $node, FALSE, $page)); - $node->teaser = implode('', _content_field_invoke('view', $node, TRUE, $page)); + $content = _content_field_invoke('view', $node, NULL, $page); + $node->body = implode('', $content['body']); + $node->teaser = implode('', $content['teaser']); $node->readmore = ($node->body != $node->teaser); } @@ -330,6 +331,7 @@ function content_nodeapi(&$node, $op, $t * types. Instead, this function gets called after the type-specific hook, and * takes care of the database interface for field types that do not choose to * do their own storage. + * This routine also checks the teaser and body mode. */ function content_field($op, &$node, $field, &$node_field, $teaser, $page) { $db_info = content_database_info($field); @@ -478,15 +480,34 @@ function _content_field_invoke($op, &$no $module = $field_types[$field['type']]['module']; $function = $module .'_field'; if (function_exists($function)) { - $result = $function($op, $node, $field, $node_field, $teaser, $page); + switch ($op) { + case 'view': + // show this field only in the teaser or in both teaser and body + if ($field['widget']['show_in_teaser']) { + $result = $function($op, $node, $field, $node_field, TRUE, $a3, $a4); + if (isset($result)) { + $return['teaser'][] = $result; + } + } + // show this field only in the body or in both teaser and body + if ($field['widget']['show_in_full_article']) { + $result = $function($op, $node, $field, $node_field, FALSE, $a3, $a4); + if (isset($result)) { + $return['body'][] = $result; + } + } + break; + default: + $result = $function($op, $node, $field, $node_field, $a2, $a3, $a4); if (is_array($result)) { $return = array_merge($return, $result); } else if (isset($result)) { $return[] = $result; } + break; + } } - $db_info = content_database_info($field); if (count($db_info['columns'])) { $result = content_field($op, $node, $field, $node_field, $teaser, $page); @@ -557,7 +578,7 @@ function _content_types($reset = FALSE) $type_result = db_query('SELECT * FROM {node_type} nt ORDER BY nt.type_name ASC'); while ($type = db_fetch_object($type_result)) { $type->fields = array(); - $field_result = db_query("SELECT nfi.field_name, nfi.weight, nfi.label, nfi.widget_type, nfi.widget_settings, nfi.description, nf.type, nf.global_settings, nf.required, nf.multiple, nf.db_storage FROM {node_field_instance} nfi LEFT JOIN {node_field} nf ON nfi.field_name = nf.field_name WHERE nfi.type_name = '%s' ORDER BY nfi.weight ASC, nfi.label ASC", $type->type_name); + $field_result = db_query("SELECT nfi.field_name, nfi.weight, nfi.label, nfi.widget_type, nfi.widget_settings, nfi.description, nfi.show_in_teaser, nfi.show_in_full_article, nf.type, nf.global_settings, nf.required, nf.multiple, nf.db_storage FROM {node_field_instance} nfi LEFT JOIN {node_field} nf ON nfi.field_name = nf.field_name WHERE nfi.type_name = '%s' ORDER BY nfi.weight ASC, nfi.label ASC", $type->type_name); while ($field = db_fetch_array($field_result)) { $field_settings = $field['global_settings'] ? unserialize($field['global_settings']) : array(); $widget_settings = $field['widget_settings'] ? unserialize($field['widget_settings']) : array(); @@ -573,6 +594,10 @@ function _content_types($reset = FALSE) unset($field['label']); $field['widget']['description'] = $field['description']; unset($field['description']); + $field['widget']['show_in_teaser'] = $field['show_in_teaser']; + unset($field['show_in_teaser']); + $field['widget']['show_in_full_article'] = $field['show_in_full_article']; + unset($field['show_in_full_article']); $field['type_name'] = $type->type_name; $type->fields[$field['field_name']] = $field; }