I need to compare two fields using template_preprocess_field().
I've got a field date and a boolean field. Field date collect start and end date but if it's one day event, I need to show "start date - one day"
If you don't collect the end date, it will be the same date of the start date. Of course I can compare start date and end date and if they are the same I will show "one day" but if the event is still running (so I won't collect the end date), I should show "on air"
So I'm trying this
function bartik_preprocess_field(&$variables) {
//here I call the date field
if($variables['element']['#field_name'] == 'field_duration') {
$starttotime = time($variables['element']['#items'][0]['value']); // convert it in time
$starttodate = date('d-m-y', $starttotime); // formatting date
// check if start date and end date are similar
if ($variables['element']['#items'][0]['value'] == $variables['element']['#items'][0]['value2']) {
// HERE I NEED TO CHECK THE OTHER FIELD
if (HERE THE FIELD ONE DAY == 0) {
$variables['items'][0]['#markup'] = $starttodate." - One day";
} else {
$variables['items'][0]['#markup'] = $starttodate." - On air";}
}
}
}