OK, I feel brave today, and although I could get hate (love?) mail for this, I wanted to give it a go, see what the community thinks.
This is something that has bothered me (and others) for some time in CCK, and I see it stil in d7 fields. The current situation is such that for all fields, no matter whether they have a single value, or several, the markup is like this:
<div class="field field-name-body field-type-text-with-summary field-label-hidden">
<div class="field-items">
<div class="field-item even" property="content:encoded">
....
</div>
</div>
</div>
That gives us two levels of unnecessary divs. What I propose would get you:
<div class="field field-name-body field-type-text-with-summary field-label-hidden">
....
</div>
It makes more sense to me, anyway, and I feel a lot of themers who care probably already do something similar in their theme implementations.
I've taken the initiative to draft up the patch, please let me know what you think if this is something to consider at all or not, and if we should approach it a different way.
Comment | File | Size | Author |
---|---|---|---|
#7 | 935878-field_single_markup-7.patch | 3.51 KB | pcambra |
#4 | 935878-field_single_markup-4.patch | 1.22 KB | pcambra |
field-single-markup.patch | 1.4 KB | Manuel Garcia | |
Comments
Comment #1
Manuel Garcia CreditAttribution: Manuel Garcia commentedAlso, you may not consider this a bug, but well, depends what you take is on the whole clean markup issue within a CMS. Feel free to change to a feature request, but let's not start a flame war because of this =)
Comment #3
swentel CreditAttribution: swentel commentedThis more a feature request, but a valid one though. The patch should also make sure it changes the example field template file.
Comment #4
pcambraHere's a reroll of the patch, not sure about where is the example field template field, though
Comment #5
swentel CreditAttribution: swentel commentedThat tpl file is located in the theme directory of the field module
Comment #7
pcambraSo it seems we can't simplify as much as desired for single valued fields as there are RDF properties added to the markup, such as "content:encoded" here's the change revisited.
I haven't been able to just remove the class from the theme function as it renders the properties wrongly if I remove it:
$output .= '<div class="" ' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</div>';
vs.
$output .= '<div ' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</div>';
Comment #10
Manuel Garcia CreditAttribution: Manuel Garcia commentedComment #11
Manuel Garcia CreditAttribution: Manuel Garcia commentedLooks like significant effort in this direction is being done here #2214241: Field default markup - removing the divitis, marking as duplicate.
Comment #12
Manuel Garcia CreditAttribution: Manuel Garcia commented