public function field_timer_county_date_field_base::renderItems in Field Timer 7.2
@inheritdoc
Overrides field_timer_county_base::renderItems
File
- includes/
field_timer_county.inc, line 403 - Help file. Contains help classes to perform field_timer_county formatter related actions.
Class
- field_timer_county_date_field_base
- Base class for field_timer_text formatter and date field types.
Code
public function renderItems($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$settings = $display['settings'];
$elements = $settings['fromto'] != 'to' ? parent::renderItems($entity_type, $entity, $field, $instance, $langcode, $items, $display) : array();
$info = entity_get_info($entity_type);
$id_key = $info['entity keys']['id'];
foreach ($items as $delta => $item) {
if (!empty($settings['title']) && $settings['fromto'] != 'to') {
$elements[$delta]['#markup'] = '<span class="field-timer-start-date-title">' . $settings['title'] . '</span> ' . $elements[$delta]['#markup'];
}
if ($settings['fromto'] == 'both' && !empty($field['settings']['todate'])) {
$elements[$delta]['#markup'] = '<div class="field-timer-start-date">' . $elements[$delta]['#markup'] . '</div>';
}
if ($settings['fromto'] != 'from' && !empty($field['settings']['todate'])) {
$title = !empty($settings['title2']) ? '<span class="field-timer-end-date-title">' . $settings['title2'] . '</span> ' : '';
$time = '<div id="county-' . $entity_type . '_' . $entity->{$id_key} . '_' . $field['field_name'] . '_' . $delta . '_2" ' . 'style="background: ' . $settings['background2'] . ';"></div>';
if ($settings['fromto'] == 'to') {
$elements[$delta] = array(
'#type' => 'markup',
'#markup' => $title . $time,
);
}
else {
$elements[$delta]['#markup'] .= '<div class="field-timer-end-date">' . $title . $time . '</div>';
}
}
}
return $elements;
}