Getting custom body class from node field I would need to get a custom body class, so that admin can set the class. At the moment I have field on page node type where I try to get it. The code what I have is below but it doesn't seem to work that smoothly. Something it prints two body classes (like this &lt;body class="classes comes here" class="another set of classes"&gt;) It's in template.php and preprocess_html function.

$node = menu_get_object();
if ($node &amp;&amp; isset($node-&gt;nid)) {

    $field_bClass = field_get_items('node', $node, 'field_bClass');

    if (!empty($field_bClass)) {
        $field_field_bClass_output = field_view_value('node', $node, 'field_bClass', $field_bClass[0], array(
            'type' =&gt; 'value'
        ));

        $vars['classes_array'][] = $field_field_bClass_output['#markup'];

    }
}


Is that corrrect and what should be done difrently?
function TEMPLATE_preprocess_html(&amp;$vars) {
    $node = menu_get_object();
    if ($node &amp;&amp; isset($node-&gt;nid)) {
        $field_body_class = field_get_items('node', $node, 'field_body_class');

        if (isset($field_body_class[0]['value'])) {
            $vars['classes_array'][] = $field_body_class[0]['value'];
        }
    }
}


This is how it would look today in Drupal 7, assuming your field name is what it is in the example. (The difference with the other answer being instead of $vars['attributes_array']['class'][] using $vars['classes_array'][])