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 <body class="classes comes here" class="another set of classes">
) It's in template.php and preprocess_html function.
$node = menu_get_object();
if ($node && isset($node->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' => 'value'
));
$vars['classes_array'][] = $field_field_bClass_output['#markup'];
}
}
Is that corrrect and what should be done difrently?
if (!empty($field___class)) {...
, but don't have a variable called$field___class
(there's one called$field_bClass
instead)?