Hi all
I've been wracking my brain over something I'm sure is very simple, but it's driving me mad! I need to iterate through a DataObjectSet to find any results that fall within a specific date range so that I can highlight a current event. I think I'm close to the result, but I just can't figure out how to add a value to my DataObjectSet to flag this result in my template.
Here's my code - any advice most welcome!
function ExhibitionSydney() {
$now = date("Y-m-d",time());
// Retrieve all Exhibitions
$exhibitions = DataObject::get('Exhibition', '','DateFrom DESC');
// Iterate through Exhibitions to find any that fall on the current date
foreach($exhibitions as $exhibition){
if ( $now >= $exhibition->DateFrom && $now <= $exhibition->DateTo ) {
// if the result falls within the current date, add Current=>true to the dataobjectset
???????
}
}
return $exhibitions;
}
I'm running SS 2.3.7
Thanks for any assistance in advance,
Y