In your theme, you can implement hook_preprocess_page(&$variables)
were you can retrieve the currently displayed content (if any) as $variables['node']
. From there, you can retrieve the value of a date field using field_get_items()
and use that value to assign classes to the <body>
of the page in $variables['classes_array']
.
function THEME_preprocess_page(&$variables) {
if (($node = $variables['node']) && ($node->type == 'report')) {
if ($items = field_get_items('node', $node, 'field_report_date')) {
$variables['classes_array'][] = drupal_clean_css_identifier('report-month-' . format_date($items[0], 'custom', 'F'));
}
}
}