1

I'm using Drupal with Views, which outputs an unformatted list of news titles (accompanied with dates). Example output of my View:

Example output of my View

Some of the news titles need to change font color or size. For example, if the chosen taxonomy term is "hot" then the font size of title should be 8px.

I think I need a CSS class to be inserted for tagged news, but I can't figure out how to do this.

1

Views supports tokens to generate CSS classes in the HTML output of a field. Below a screenshot depicting an example where I have added the fields 'Tags' and 'Title' from the default Article content type. In this way, the chosen taxonomy terms are added as CSS classes and you can apply the appropriate styling using CSS.

HTML output of a field in Views, using token to generate the CSS class(es)

In order to see the list of available tokens in your View, checkout the section 'Rewrite results' -> 'Rewrite the output of this field' -> 'Replacement patterns' in the configuration screen of the field (you don't need to actually rewrite the output, however, this is the location where you can find the list of supported tokens for the particular field).

0

You can do this by using CSS Injector.

Allows administrators to inject CSS into the page output based on configurable rules. It's useful for adding simple CSS tweaks without modifying a site's official theme. The CSS is added using Drupal's standard drupal_add_css() function and respects page caching, etc. The 2.x brach leverages CTools so CSS can be included with Feature changes (ie. CSS that improves the look of a View can be packaged with the View).

HOW TO USE ?

  • tnx for this module. but cant use it. options only: Add the CSS on specific pages Add on every page except the listed pages. add on only the listed pages. Add if the following PHP code outputs a nonzero value (PHP-mode, experts only). In my case i need change title when editor chose "hot" check box. – dedkola May 20 '15 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.