Jump to:

10931 Posts in 2614 Topics by 1810 members

All other Modules

SilverStripe Forums » All other Modules » Event Calendar Suggestion: Make defaultFutureMonths configurable

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 714 Views
  • jak
    Avatar
    Community Member
    46 Posts

    Event Calendar Suggestion: Make defaultFutureMonths configurable Link to this post

    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).

  • UncleCheese
    Avatar
    4085 Posts

    Re: Event Calendar Suggestion: Make defaultFutureMonths configurable Link to this post

    You can just do it in your_config.php.

    Calendar::$defaultFutureMonths = 10;

  • jak
    Avatar
    Community Member
    46 Posts

    Re: Event Calendar Suggestion: Make defaultFutureMonths configurable Link to this post

    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.

    714 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.