Skip to main content
1 of 2
J. Reynolds
  • 6.4k
  • 2
  • 17
  • 28

The following will add the class 'hello' to the li tag. I used a view with machine name 'dates' and a display name of 'page'. The time field is the node created time. You can just install Devel and uncomment the dpm($vars) statement to get what you need. I also left the conditional logic up to you.

Put this in your theme's template.php file:

function MYTHEME_preprocess_views_view_list(&$vars) {
  if ($vars['view']->name == 'dates' && $vars['view']->current_display == "page") {
    // dpm($vars); //uncomment to see variables
    foreach($vars['view']->result as $key => $value){
      $timestamp = $value->node_created;
      if ($timestamp) { // add whatever conditional logic you need here
        $vars['classes_array'][$key] .= ' hello'; // note the space in front of class
      }
    }
  }
}
J. Reynolds
  • 6.4k
  • 2
  • 17
  • 28