0
votes

In my Drupal template, I have a view loading multiple content types as fields. How can I apply css for certain types/add a class to the rows of a specific node type?

2

2 Answers

0
votes

My solution was to override node--[contenttype].tpl.php and add the class after the print $classes

0
votes

My approach to this would be to add a implementation of hook_preprocess_node(). As you have not stated the version of drupal you are using, I am going to presume you are using drupal 7. https://api.drupal.org/api/drupal/modules%21node%21node.module/function/template_preprocess_node/7

/**
 * Implements hook_preprocess_node().
 */
function hook_preprocess_node(&$variables) {
  $n = $variables['node'];
  if ($n->type != 'content_type_to_match') {
    return;
  }

  $variables['classes_array'][] = 'example-class';
}