summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaren Stevenson2011-02-02 21:47:45 (GMT)
committer Karen Stevenson2011-02-02 21:47:45 (GMT)
commitf2e8ca36ee0abca8fa4d05d82a400ce8d5c462b0 (patch)
tree4faaf2ce7e901cf8a74636c4305243b339087b5b
parent19ffbc96727801278f107b3fb1768d96e2439297 (diff)
#766734 Restructure multigroup field layout to be consistent with other fieldgroups, and use content_get_nested_elements() to grab the right values no matter how the fields are structured.
-rw-r--r--content.module29
-rw-r--r--modules/content_multigroup/content_multigroup.node_view.inc16
2 files changed, 16 insertions, 29 deletions
diff --git a/content.module b/content.module
index e62ef48..cd06d45 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 b7d120a..389532b 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;