Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It can be really useful to have token support so can style something in a listing (or a view see #1831208: Use Tokens/Replacement Pattern in CSS Declaration in Views).
Comment | File | Size | Author |
---|---|---|---|
#1 | color_field-token_support-1884164-1.patch | 1.55 KB | yannickoo |
Comments
Comment #1
yannickooYou can attribute authorship to me. You can easily create the git commit message with Dreditor :)
Comment #2
celstonvml CreditAttribution: celstonvml commentedPatch from #1 works beautifully.
Comment #3
hoangdk80 CreditAttribution: hoangdk80 commentedPatch works but it doesn't make available tokens such as field_title, field_body or any other replacement token generated by the view fields.
To my usage these are the tokens we need.
My use case is simple: I have a content-type with a field_colored. Any content of that type can have another color, which, to me, is the purpose of this module. My goal is to display in the view, every node with it's color on the background of it's row.
I cannot really achieve this without third part modules.
Comment #4
drupal a11y CreditAttribution: drupal a11y commentedWhich third party modules did you use?
I have a similar problem and the most easiest way would be that instead of hex-values a css-classname could be assigned or a field-formatter which uses the color-value.
In my special issue I have a field-collection with a color field & title and want to change the background-color via views.
But when I try to use the value in a "custom text field", cause the "#hex-value" can´t be used as a classname cause of the "#" the following output does not work. I use Semantic fields !!!
The "[field_colorfield]" is just filled in in the first div.
Comment #5
drupal a11y CreditAttribution: drupal a11y commentedCan anybody create a short tutorial with some screenshots for this?
Comment #6
yannickooOh, the patch from #1 was already committed in 1ebf14d, so marking this issue as fixed.
@mori go to "Manage display" and select "CSS Declaration" as field formatter. Then you can enter selector(s) and which property you want to modify, possible options are text color and background color. The textarea for the selectors allows you to use tokens so you could change the text color of
#node-[node:nid]
means#node-12
.Comment #7
drupal a11y CreditAttribution: drupal a11y commentedIn my special case I have a multivalue list of field-collection-items in a views-block and each item should have it´s own selected backgroundcolor.