So in Views you can add a CSS class (under style settings) to your field. I need to print the same class in a parent div of the calendar module.
The fields are rendered to calendar content with the calendar-item.tpl.php That file looks like this:
$index = 0;
?>
<div class="<?php print !empty($item->class) ? $item->class : 'item'; ?>">
<div class="view-item view-item-<?php print $view->name ?>">
<div class="calendar <?php print $item->granularity; ?>view">
<?php print theme('calendar_stripe_stripe', array('item' => $item)); ?>
<div class="<?php print $item->date_id ?> contents">
<?php foreach ($rendered_fields as $field): ?>
<?php if ($index++ == 0 && (isset($item->continuation) && $item->continuation)) : ?>
<div class="continuation">«</div>
<?php endif;?>
<?php print $field; ?>
<?php endforeach; ?>
</div>
<?php if (isset($item->continues) && $item->continues) : ?>
<div class="continues">»</div>
<?php else : ?>
<div class="cutoff"> </div>
<?php endif;?>
</div>
</div>
</div>
So I need to get that class in the first DIV
<div class="<?php print !empty($item->class) ? $item->class : 'item' . ENTER-FIELDCLASS-HERE; ?>">
I've been looking in the VIEWS module and the code taht checks if you entered a CSS class should be this part in the THEME.inc file:
if ($classes = $object->handler->element_classes($view->row_index)) {
if ($class) {
$class .= ' ';
}
$class .= $classes;
}
A more complete part:
$previous_inline = FALSE;
$vars['fields'] = array(); // ensure it's at least an empty array.
foreach ($view->field as $id => $field) {
// render this even if set to exclude so it can be used elsewhere.
$field_output = $view->style_plugin->get_field($view->row_index, $id);
$empty = $field->is_value_empty($field_output, $field->options['empty_zero']);
if (empty($field->options['exclude']) && (!$empty || (empty($field->options['hide_empty']) && empty($vars['options']['hide_empty'])))) {
$object = new stdClass();
$object->handler = &$view->field[$id];
$object->inline = !empty($vars['options']['inline'][$id]);
$object->element_type = $object->handler->element_type(TRUE, !$vars['options']['default_field_elements'], $object->inline);
if ($object->element_type) {
$class = '';
if ($object->handler->options['element_default_classes']) {
$class = 'field-content';
}
if ($classes = $object->handler->element_classes($view->row_index)) {
if ($class) {
$class .= ' ';
}
$class .= $classes;
}
$pre = '<' . $object->element_type;
if ($class) {
$pre .= ' class="' . $class . '"';
}
$field_output = $pre . '>' . $field_output . '</' . $object->element_type . '>';
}
Not the most clear code to me. It can't be that hard. If only something like $field->class would work!
Thanks in advance!