I have created an Events-Overview - Site
Each Event-entry has a Start- and Enddate.
Now I want to hide the Events when the Enddate
has passed. This is my Code:
Blueprint
title: Events Element
pages: false
files: true
fields:
caption:
label: Caption
type: textarea
fields:
Main Content Meta:
label: Main Content
type: headline
title:
label: Title
type: text
main_title:
label: Main Title
type: text
category:
label: Category
type: tags
type:
label: Type
type: text
startdate:
label: Start Date
type: date
format: MM/DD/YYYY
width: 1/2
enddate:
label: End Date
type: date
format: MM/DD/YYYY
width: 1/2
I have to declare my startdate/enddate like this: <?php $eventStartdate = $element->date('%e. %b. %Y', 'startdate'); $eventEnddate = $element->date('%e. %b. %Y', 'enddate'); ?>
I don’t know how to declare them before the foreeach loop.
With this code i can output the dates in a nice
readable format: <?php $eventStartdate = $element->date('%e. %b. %Y', 'startdate'); $eventEnddate = $element->date('%e. %b. %Y', 'enddate'); ?>
For example outputs: 1. Feb. 2016 - 14. Mär. 2016
But this declaration happens after i define $element.
I need to make this before the foreach - loop.
Saludos, Funkybrotha
ps. The code works like posted in my first post.
I’m just missing the ->filterby… enddate - part.
Thanx a lot! It works!!! Yeah!!!
I must say i’m really impressed with the quality of the support in this forum.
One small add. question:
How can I add one day to the Filter?
If I create an Event from yesterday to today…
It disappears already today. But I want to show the Event till the Enddate has passed.
Is it possible to add like +1 day or 24h?
‘>=’ does not work.
I’ve read something that the returned value
by time() is minutes and not a day - value?
Do I need to convert that to something
different?