How to add the value of a drupal field to the class of a wrapper div Working on a clients drupal 7 site, I have a content type that is promoted to the front page. The content type has a list field, I want to use the value of that field to add a class to the wrapper div on the node teasers populated to the front page. For example the html output would be something like this:

&lt;div class="field_value"&gt;
content
&lt;/div&gt;


I'd prefer not to have to use a view or nodequeue to do this as it's easier on the client administering their site to simply promote items to front page. 

I've been trying to add the class in the node.tpl.php file but for some reason I just can't get it to work. I've tried creating a preprocess variable in the template.php file but all I get in the output is: div class="Array".

Does anyone have any ideas on why I'm just getting the word "Array" output? or any ideas on how to solve my problem?

Thanks
Something like this should do it:

function MYTHEME_preprocess_node(&amp;$vars) {
  if ($vars['node'] == 'some_type') {
    $field_items = field_get_items('node', $vars['node'], 'field_name');
    $first_item = array_shift($field_items);

    $value = $first_item['value'];

    // If you want to write &lt;div class="&lt;?php echo $extra_class; ?&gt;"&gt;... in your template file:
    $vars['extra_class'] = $value;

    // Or if you want to add this to the classes on the main node &lt;div&gt;:
    $vars['classes_array'][] = $value;
  }
}