The current 7.x-3.16 branch was not working the way I expected. For readability, my field_tags are written with spaces (i.e. "my class") . When they are output as classes, the whitespace needs to be replaced with a non-whitespace character such as a hyphen. The author of this related thread (https://www.drupal.org/node/2752617) had an issue where multi-value fields were output as a single hyphenated class, and a solution was deployed in 7.x-3.16. Unfortunately, that solution will output tags containing whitespace with whitespace in tact, turning what should be one class into multiple classes. The solution in my patch handles both multi-value tags and tags containing whitespace.

If a single tag is made up of more than one word, separated by whitespace this patch will replace the whitespace with hyphens. If the tag is already hyphenated, it is left alone. If field_tags has multiple values, the get_row_class function pulls the value of the multi_type separator and inserts it into a preg_replace pattern. Multiple tags are preserved as multiple classes.

Files: 

Comments

drewble created an issue. See original summary.

drewble’s picture

Here is my patch.

drewble’s picture

Title: Update to 7.x-3.16 breaks displays using » Update to 7.x-3.16 breaks displays using field_tags as classes with spaces