? cck_empty_fields.patch ? cck_exclude_from_content-300368-16.patch ? cck_exclude_from_content-300368-4.patch Index: content.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/content.module,v retrieving revision 1.301.2.70 diff -u -p -r1.301.2.70 content.module --- content.module 9 Oct 2008 00:24:49 -0000 1.301.2.70 +++ content.module 9 Oct 2008 14:08:31 -0000 @@ -200,6 +200,9 @@ function content_theme() { 'path' => $path, 'arguments' => array('form' => NULL), ), + 'content_excluded_fields' => array( + 'arguments' => array(), + ), 'content_view_multiple_field' => array( 'arguments' => array('items' => NULL, 'field' => NULL, 'data' => NULL), ), @@ -738,11 +741,16 @@ function content_field($op, &$node, $fie } // 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, '#weight' => $field['widget']['weight'], + '#post_render' => array('content_field_wrapper_post_render'), + '#field_name' => $field['field_name'], + '#type_name' => $node->type, + '#context' => $context, ); $addition = array($field['field_name'] => $wrapper); @@ -2024,6 +2032,54 @@ function content_default_value(&$form, & return (array) $default_value; } + /** + * 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'], $element['#context']); + 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. + * + * @param $context + * The context for which the node is being rendered. + * Can be one of the following values : + * - 'teaser' + * - 'full' + * - NODE_BUILD_SEARCH_INDEX + * - NODE_BUILD_SEARCH_RESULT + * - NODE_BUILD_RSS + * - NODE_BUILD_PRINT + * + * @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, $context) { + return array(); +} + /** * Theme preprocess function for field.tpl.php. * Index: modules/fieldgroup/fieldgroup.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/modules/fieldgroup/fieldgroup.module,v retrieving revision 1.79.2.34 diff -u -p -r1.79.2.34 fieldgroup.module --- modules/fieldgroup/fieldgroup.module 6 Oct 2008 15:11:39 -0000 1.79.2.34 +++ modules/fieldgroup/fieldgroup.module 9 Oct 2008 14:08:33 -0000 @@ -573,12 +573,17 @@ function fieldgroup_nodeapi(&$node, $op, } } - // 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, '#weight' => $group['weight'], + '#post_render' => array('fieldgroup_wrapper_post_render'), + '#group_name' => $group_name, + '#type_name' => $node->type, + '#context' => $context, ); $node->content[$group_name] = $wrapper; @@ -587,6 +592,17 @@ function fieldgroup_nodeapi(&$node, $op, } } +/** + * 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'], $element['#context']); + if (in_array($element['#group_name'], (array) $excluded)) { + $content = ''; + } + return $content; +} + /* * Get the group name for a field. * If the field isn't in a group, FALSE will be returned.