How do I add a class to a row based on the value of a field in that row? I have a view with a page display showing a list of events. I'd like to add a class to the rows of those events that are in the past.

The problem I have is that views-view-list.tpl.php doesn't have access to the values of fields within the rows. 

And I can use views-view-fields.tpl.php to check the date field of one row, and wrap each field in that row with a div or span based on whether or not the date field is in the past.

I just can't figure out how to use the value of a field within a row to wrap the whole row in something with a class.
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(&amp;$vars) {
  if ($vars['view']-&gt;name == 'dates' &amp;&amp; $vars['view']-&gt;current_display == "page") {
    // dpm($vars); //uncomment to see variables
    foreach($vars['view']-&gt;result as $key =&gt; $value){
      $timestamp = $value-&gt;node_created;
      if ($timestamp) { // add whatever conditional logic you need here
        $vars['classes_array'][$key] .= ' hello'; // note the space in front of class
      }
    }
  }
}


An alternative method is as follows:

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

function MYTHEME_preprocess_views_view_fields(&amp;$vars) {
  if ($vars['view']-&gt;name == 'dates' &amp;&amp; $vars['view']-&gt;current_display == "page") {
    $timestamp = $vars['row']-&gt;node_created;
    if ($timestamp &lt; strtotime('now')) {
      $vars['classes_array'][] = 'bye';
    }
  }
}


and use this views-view-fields--VIEWNAME.tpl.php file:

&lt;div class="&lt;?php print $classes;?&gt;"&gt;
&lt;?php foreach ($fields as $id =&gt; $field): ?&gt;
  &lt;?php if (!empty($field-&gt;separator)): ?&gt;
    &lt;?php print $field-&gt;separator; ?&gt;
  &lt;?php endif; ?&gt;

  &lt;?php print $field-&gt;wrapper_prefix; ?&gt;
  &lt;?php print $field-&gt;label_html; ?&gt;
  &lt;?php print $field-&gt;content; ?&gt;
  &lt;?php print $field-&gt;wrapper_suffix; ?&gt;
&lt;?php endforeach; ?&gt;
&lt;/div&gt;