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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Manuel Garcia’s picture

Also, 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 =)

Status: Needs review » Needs work

The last submitted patch, field-single-markup.patch, failed testing.

swentel’s picture

Version: 7.x-dev » 8.x-dev
Category: bug » feature

This more a feature request, but a valid one though. The patch should also make sure it changes the example field template file.

pcambra’s picture

Status: Needs work » Needs review
FileSize
1.22 KB

Here's a reroll of the patch, not sure about where is the example field template field, though

swentel’s picture

That tpl file is located in the theme directory of the field module

/Users/drupal/drupal/core/modules/field/theme
swenteldoos-2:theme swentel$ ls -al
total 24
drwxr-xr-x   5 swentel  staff   170 Sep  1 12:35 .
drwxr-xr-x  17 swentel  staff   578 Aug 30 22:48 ..
-rw-r--r--   1 swentel  staff   249 Aug 29 22:43 field-rtl.css
-rw-r--r--   1 swentel  staff   472 Aug 29 22:43 field.css
-rw-r--r--   1 swentel  staff  2559 Aug 29 22:43 field.tpl.php

Status: Needs review » Needs work

The last submitted patch, 935878-field_single_markup-4.patch, failed testing.

pcambra’s picture

Status: Needs work » Needs review
FileSize
3.51 KB

So 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>';

Status: Needs review » Needs work

The last submitted patch, 7: 935878-field_single_markup-7.patch, failed testing.

Manuel Garcia’s picture

Issue summary: View changes
Issue tags: +dreammarkup, +frontend, +Twig
Manuel Garcia’s picture

Status: Needs work » Closed (duplicate)
Related issues: +#2214241: Field default markup - removing the divitis

Looks like significant effort in this direction is being done here #2214241: Field default markup - removing the divitis, marking as duplicate.

Manuel Garcia’s picture

Issue tags: -Twig