diff --git a/content.module b/content.module index e62ef48cc973f0a1bd9abc854cfdf7e4ae957aa1..cd06d4501e4c4f044a46d35cff1b424246cb3cc8 100644 --- a/content.module +++ b/content.module @@ -848,22 +848,15 @@ function content_field($op, &$node, $field, &$items, $teaser, $page) { // The location of the field's rendered output depends on whether the // field is in a fieldgroup or not. - $wrapper = NULL; - if (isset($node->content[$field['field_name']])) { - $wrapper = $node->content[$field['field_name']]; - } - elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) { - $wrapper = $node->content[$group_name]['group'][$field['field_name']]; - } - - if ($wrapper) { + $wrappers = content_get_nested_elements($node->content, $field['field_name']); + foreach ($wrappers as $wrapper) { $element = $wrapper['field']; // '#single' is not set if the field is hidden or inaccessible. if (isset($element['#single'])) { if (!empty($element['#single'])) { // Single value formatter. foreach (element_children($element['items']) as $delta) { - // '#chilren' is not set if the field is empty. + // '#children' is not set if the field is empty. $items[$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : ''; } } @@ -885,19 +878,11 @@ function content_field($op, &$node, $field, &$items, $teaser, $page) { // The location of the field's rendered output depends on whether the // field is in a fieldgroup or not. - $wrapper = NULL; - if (isset($node->content[$field['field_name']])) { - $wrapper = $node->content[$field['field_name']]; - } - elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) { - $wrapper = $node->content[$group_name]['group'][$field['field_name']]; + $wrappers = content_get_nested_elements($node->content, $field['field_name']); + foreach ($wrappers as $wrapper) { + // '#children' is not set if the field is empty. + $addition[$field['field_name'] .'_rendered'] .= isset($wrapper['#children']) ? $wrapper['#children'] : ''; } - - if ($wrapper) { - // '#chilren' is not set if the field is empty. - $addition[$field['field_name'] .'_rendered'] = isset($wrapper['#children']) ? $wrapper['#children'] : ''; - } - return $addition; case 'prepare translation': diff --git a/modules/content_multigroup/content_multigroup.node_view.inc b/modules/content_multigroup/content_multigroup.node_view.inc index b7d120a9e39561c199c6be10a90c3e9db35fd475..389532bd72722b4245e5c267ed5dc11ab002cec3 100644 --- a/modules/content_multigroup/content_multigroup.node_view.inc +++ b/modules/content_multigroup/content_multigroup.node_view.inc @@ -54,7 +54,6 @@ function _content_multigroup_fieldgroup_view(&$node, &$element, $group, $context $group_deltas = range(0, $group_multiple - 1); break; } - foreach ($group_deltas as $index => $delta) { $element[$delta] = array( '#title' => ($show_label == 'above' && !empty($subgroup_labels[$index]) ? check_plain(t($subgroup_labels[$index])) : ''), @@ -64,15 +63,18 @@ function _content_multigroup_fieldgroup_view(&$node, &$element, $group, $context // Create a pseudo node that only has the value we want in this group and // pass it to the formatter. - // Default implementation of content-field.tpl.php uses a different CSS - // class for inline labels when delta is zero, but this is not needed in - // the context of multigroup, so we place the field into index 1 of the - // item list. Note that CSS class "field-label-inline" is overridden in the - // multigroup stylesheet because here labels should always be visible. + + // @TODO Watch this change and be sure it doesn't break anything else. + // The delta was previously always set to '1' to keep CCK's inline label + // from assigning a class of 'first'. But changing it back to the right + // delta for the individual item makes the formatters easier to manage + // since the delta is always the correct delta and not occasionally + // a bogus value. It aslo fixes issues like http://drupal.org/node/766734 + // by keeping the layout of multigroups the same as other fieldgroups. foreach (array_keys($group_fields) as $field_name) { if (isset($node->content[$field_name])) { $node_copy->content[$field_name]['field']['items'] = array( - 1 => isset($node->content[$field_name]['field']['items'][$delta]) ? $node->content[$field_name]['field']['items'][$delta] : NULL, + $delta => isset($node->content[$field_name]['field']['items'][$delta]) ? $node->content[$field_name]['field']['items'][$delta] : NULL, ); $element[$delta][$field_name] = $node_copy->content[$field_name]; $element[$delta][$field_name]['#delta'] = $delta;