Index: modules/fieldgroup/fieldgroup.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/modules/fieldgroup/fieldgroup.module,v retrieving revision 1.79.2.12 diff -u -r1.79.2.12 fieldgroup.module --- modules/fieldgroup/fieldgroup.module 26 Aug 2008 13:56:17 -0000 1.79.2.12 +++ modules/fieldgroup/fieldgroup.module 26 Aug 2008 22:58:56 -0000 @@ -444,17 +444,30 @@ } } - // The wrapper lets us get the themed output for the whole group - // once the $node->content has been rendered. - // See fieldgroup_preprocess_node(). + // The wrapper lets us get the themed output for the group + // to populate the $GROUP_NAME_rendered variable for node templates, + // and hide it from the $content variable if needed. + // See fieldgroup_preprocess_node(), theme_fieldgroup_wrapper(). $wrapper = array( 'group' => $element, + '#post_render' => array('fieldgroup_wrapper_post_render'), + '#group_name' => $group_name, + '#type_name' => $node->type, ); $node->content[$group_name] = $wrapper; } break; } +/** + * Hide specified fields from the $content variable in node templates. + */ +function fieldgroup_wrapper_post_render($content, $element) { + $excluded = theme('content_excluded_fields', $element['#type_name']); + if (in_array($element['#group_name'], (array) $excluded)) { + $content = ''; + } + return $content; } /* Index: content.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/content.module,v retrieving revision 1.301.2.36 diff -u -r1.301.2.36 content.module --- content.module 25 Aug 2008 15:46:11 -0000 1.301.2.36 +++ content.module 26 Aug 2008 22:58:56 -0000 @@ -216,6 +216,8 @@ 'template' => 'content-field', 'arguments' => array('element' => NULL), 'path' => $path, + 'content_excluded_fields' => array( + 'arguments' => array(), ), 'content_overview_links' => array( 'arguments' => array(), @@ -720,10 +722,14 @@ } // The wrapper lets us get the themed output for the whole field - // once the $node->content has been rendered. - // See op 'preprocess_node' below. + // to populate the $FIELD_NAME_rendered variable for node templates, + // and hide it from the $content variable if needed. + // See 'preprocess_node' op and theme_content_field_wrapper()? $wrapper = array( 'field' => $element, + '#post_render' => array('content_field_wrapper_post_render'), + '#field_name' => $field['field_name'], + '#type_name' => $node->type, ); $addition = array($field['field_name'] => $wrapper); @@ -1874,6 +1880,46 @@ } /** + + /** + * Hide specified fields from the $content variable in node templates. + */ +function content_field_wrapper_post_render($content, $element) { + $excluded = theme('content_excluded_fields', $element['#type_name']); + if (in_array($element['#field_name'], (array) $excluded)) { + $content = ''; + } + return $content; +} + +/** + * 'Theme' function. + * + * Lists fields and fieldgroups that should be excluded from + * the all-inclusive $content variable in node templates. + * The html for those are available in the $FIELD_NAME_rendered and + * $GROUP_NAME_rendered variables. + * This allows more flexibility in node templates : you can use custom markup + * around a few specific fields, and print the rest of the node with $content. + * + * @param $type_name + * The content-type of the node that is being rendered. + * + * @return + * A PHP array, listing the fields and groups that should be excluded from $content. + * Example : + * switch ($type_name) : + * case 'story': + * return array('field_foo', 'group_bar'); + * case 'page': + * return array('field_baz'); + * ); + */ +function theme_content_excluded_fields($type_name) { + return array(); +} + +/** * Process variables for field.tpl.php. * * The $variables array contains the following arguments: