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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

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

Event Calendar Suggestion: Make defaultFutureMonths configurable


Go to End


3 Posts   982 Views

Avatar
jak

Community Member, 46 Posts

29 March 2010 at 5:58am

Edited: 29/03/2010 6:00am

Hi!
I have a suggestion for the module event_calendar, namely to make $defaultFutureMonths configurable.
A patch that does this could look like this:
file: event_calendar/code/calendar.php

9c9,10
< 		'OtherDatesCount' => 'Int'
---
> 		'OtherDatesCount' => 'Int',
> 		'FutureMonths' => 'Int'
25c26,27
< 		'OtherDatesCount' => '3'
---
> 		'OtherDatesCount' => '3',
> 		'FutureMonths' => '6'
33d34
<   static $defaultFutureMonths = 6;
104c105,106
< 			new NumericField('OtherDatesCount', _t('Calendar.NUMBERFUTUREDATES','Number of future dates to show for repeating events'))
---
> 			new NumericField('OtherDatesCount', _t('Calendar.NUMBERFUTUREDATES','Number of future dates to show for repeating events')),
> 			new NumericField('FutureMonths', _t('Calendar.FUTUREMONTHS','Number of months events are shown in the future if no end date is specified'))
335c337
< 			$this->end_date = new sfDate($this->start_date->addMonth(Calendar::$defaultFutureMonths)->date());
---
> 			$this->end_date = new sfDate($this->start_date->addMonth($this->FutureMonths)->date());
394c396
< 			$start_date->subtractMonth(Calendar::$defaultFutureMonths), 
---
> 			$start_date->subtractMonth($this->FutureMonths), 
550c552
< 					$this->end_date = new sfDate($this->start_date->addMonth(Calendar::$defaultFutureMonths)->date());
---
> 					$this->end_date = null;
560c562
< 			$this->end_date = new sfDate($this->start_date->addMonth(Calendar::$defaultFutureMonths)->date());
---
> 			$this->end_date = null;
764a767
> 		

Explanation: $defaultFutureMonths is not needed anywhere outside of Calendar. The accesses in Calendar_Controller can be replaced with end_date=null which has the same effect.
I renamed $defaultFutureMonths to FutureMonths and added the necessary code to allow configuration via the silverstripe backend.

These changes are just a suggestion, nevertheless I think they would be an useful addition.

Of course the translation for the field FUTUREMONTHS would also have to be added to the language files (event_calendar/lang/en_US.php and de_DE.php).

Avatar
UncleCheese

Forum Moderator, 4102 Posts

29 March 2010 at 10:14am

You can just do it in your_config.php.

Calendar::$defaultFutureMonths = 10;

Avatar
jak

Community Member, 46 Posts

30 March 2010 at 11:16pm

Thanks, I wasn't aware of that, I am used to not being able to set class variables from the outside...

I still think that it would be good to expose this setting in the configuration backend. The reason I stumbled across this variable was because I was wondering why dates in the far future did not show up in the frontend.