Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Event Calendar - customizing default dates in date filter on frontend


Go to End


3 Posts   2026 Views

Avatar
Tomase

Community Member, 16 Posts

26 November 2009 at 12:34am

Hello,

we need help with this topic.

We have extended the event-calender with extra filters according to this tutorial: http://doc.silverstripe.org/doku.php?id=recipes:extending_the_event_calendar&s=dropdownfield%20cms%20editor

We would like the datefilter on frontend to set default dates to "today" as starttime and "today + 1 month" as endtime, (ie: Start: 25. Nov 2009 End: 25. Dec 2009 )instead of "today" as both start and end as it is now.

Does anyone have the solution for this?

Thanks,

Ã…sel T.

Attached Files
Avatar
UncleCheese

Forum Moderator, 4102 Posts

26 November 2009 at 3:52am

The start/end filters take default values that represent the current view, so if you want the end date to show today, and the end date to show today +1 month, then range for your calendar view has to be today - today+1 month. So probably the easiest thing to do would be to create an index() function to redirect to that range.

In your Calendar subclass:

function index()
{
$start = date("Ymd");
$end = date("Ymd", strtotime("+1 month"));
Director::redirect($this->Link("$start/$end"));
return;
}

I think that will work. You may have to tweak it a bit.

Avatar
Tomase

Community Member, 16 Posts

26 November 2009 at 4:08am

Thanks, it works right out of the box :-)))

Exactly what we needed!

best regards,

Ã…sel og Siv