I have a field in a node type called body_styles
.
I need to modify html.tpl.php to get the value of body_styles
to add it to the classes of the body tag.
I tried with dpm($node->content['body_styles']['#value']);
but I get nothing. I think it is because $node is not available in html.tpl.php.
how do I get a node field value in a html.tpl.php template file?
@svetlio: almost done:
The class is correctly added to $variables['classes_array'] but if I inspect the body (see my capture below the code) tag is not there
function omega_subtheme_2_preprocess_html(&$variables, $hook) {
if (arg(0) == 'node' && is_numeric(arg(1))) {
global $language;
$node = entity_load_unchanged('node', arg(1));
dpm($node -> field_body_class['und'][0]['value']);
if (isset($node -> field_body_class['und'][0]['value']) && $node -> field_body_class['und'][0]['value']){
$variables['classes_array'][] = $node -> field_body_class['und'][0]['value'];
dpm($variables['classes_array']);
}
}