Problem/Motivation

Instead of using $item_attributes, the div template just uses $attributes for every item.

Proposed resolution

Use $item_attributes instead.

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#2 fences-2568833.patch471 bytescatch

Comments

catch created an issue. See original summary.

catch’s picture

Status: Active » Needs review
StatusFileSize
new471 bytes
johnalbin’s picture

Status: Needs review » Needs work
+++ b/templates/field--fences-div.tpl.php
@@ -17,7 +17,7 @@
 <?php foreach ($items as $delta => $item): ?>
-  <div class="<?php print $classes; ?>"<?php print $attributes; ?>>
+  <div <?php print $item_attributes[$delta]; ?>>
     <?php print render($item); ?>
   </div>
 <?php endforeach; ?>

That's definitely going to break things on production sites if we no longer use $classes.

This is the problem we had when we were trying to decide which variables to use. Core has 3 divs each with their own variables:

  1. wrapper div has $classes and $attributes. The $classes one is the most important variable in all templates to themers. With $attributes possibly second.
  2. wrapper div that does not go around the field title has $content_attributes. Which is probably only used by RDF module. :-p
  3. div around each field item has $item_attributes[$delta].

We couldn't munge all of the classes together into a single div (or proper HTML5 tag) because the legacy classes would not make sense on a single target. In the end, we ignored the content and item variables.

Bug? Yeah, but by design. I'm surprised no one else has complained about it before.

I would accept a patch that merged $attributes with $item_attributes[$delta] and then figured out what to do with the classes in $item_attributes[$delta] (or just stripped the classes since that is what we are essentially doing now.)

johnalbin’s picture

I took a look at RDF module again (first time in years) and I think I can make it work. It only inserts $item_attributes into the field theme hook. hmm…

johnalbin’s picture

This is going to be a backwards-compatible-breaking change.

The problem is that some of the templates do use $item_attributes, the ul and ol templates for example. So some templates need 2 variables, attributes and item_attributes, and some templates need a combined variable… maybe called $combined_attributes?