There appears to be a bug in the way that "replacement patterns" are processed in the Element Class field of a View's Style Settings. Views: 3.0-alpha1

To reproduce, follow these steps:

  1. Create a taxonomy called "Major Food Groups"
  2. Add these terms to the new taxonomy: "Bacon", "Chocolate", and "Beer"
  3. Modify the Basic Story content type to add the taxonomy, using a select box with singular selection.
  4. Create and promote to front three stories, one for each of the three taxonomy terms.
  5. Enable the "frontpage" View.
  6. Modify the Page display, adding the Taxonomy:Term and Fields:Body fields. Sort by Taxonomy:Term ascending.
  7. Modify the Style Settings of the Fields:Body field so that it is wrapped in a DIV HTML element with an element class set to "term-[name]"
  8. Preview the results. Note that the Taxonomy:Term and Fields:Body fields are displayed correctly. But note that ALL Fields:Body fields are wrapped in a DIV with a class of "term-chocolate". In other words, the element classes array is always set to the LAST term that has been retrieved. It SHOULD use the term attached to the current row.

Comments

dawehner’s picture

I can reproduce this error.

jfinkel’s picture

It is also present in 7.x-3.0-beta3

merlinofchaos’s picture

Status: Active » Fixed

Fixed in both 6.x and 7.x

irwin nerwin’s picture

Merlin, please pardon my noobness if this is not the appropriate place to append my problem. (Correction, instruction, about such things welcomed.)

We're using Views 7.x-3.0-alpha2, page view, row style.

I set the row class to use a taxonomy field replacement value, e.g. "abc-[entity_id_1]".

The term "Petunia" results in class "abc-Petunia". Fine, so far.

The term "Aunt Petunia" results in class(es) "abc-Aunt Petunia". Oops.

I haven't tried it on the public site, but my tech partner installed alpha3 on the dev server and tells me, no change.

[Edit#2: Re-installed alpha1 and the hyphens returned. Ta-da.]

I swear, a little while ago (maybe before our last upgrade?), multiple-word terms were having spaces properly replaced with hyphens in the row class, and now they're not. I had styling based on the class with hyphens, which worked, and now of course doesn't, so it was there. I'm thinking, just maybe, this one's not me. We're kinda new to Drupal, just started (over) with D7, just moved from development to public, just launched multiple sites, doing all kinds of theming and all the thousand set-up switches (Wheee! Agghhh!), but I don't think I changed anything that would have done this. It's not like there's a lot of entity choices, or the full Tokens roster available.

Speaking of which, while I have you here, what I really want (as I said in another lonely little post) is not to use the taxonomy term itself but a taxonomy added field value (in my case, a subfolder name for each term, slightly different from the term, already lower-cased and hyphenated, perfect for use as a class), but that's apparently not available to Views. Yet. Right?

[ag. quick edit to fix link in last graph]

dawehner’s picture

Can you please test the latest patch in #1111258: Allow underscores in CSS classes ?

irwin nerwin’s picture

The patch, applied to the latest views dev (release date: April 3rd) does not seem to replace spaces.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.