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).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yannickoo’s picture

Status: Active » Needs review
FileSize
1.55 KB

You can attribute authorship to me. You can easily create the git commit message with Dreditor :)

celstonvml’s picture

Patch from #1 works beautifully.

hoangdk80’s picture

Patch 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.

drupal a11y’s picture

Which 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 !!!

<div class="itemWrapper [field_displayoptions] [field_colorfield] "  style="background-color: [field_colorfield]  ><div style=background-color: [field_colorfield] >

The "[field_colorfield]" is just filled in in the first div.

drupal a11y’s picture

Can anybody create a short tutorial with some screenshots for this?

yannickoo’s picture

Status: Needs review » Fixed

Oh, 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.

drupal a11y’s picture

In 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.

Status: Fixed » Closed (fixed)

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