Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » Event Calendar filter troubles

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 950 Views
  • Eric26
    Community Member
    2 Posts

    Event Calendar filter troubles Link to this post

    Hi there,

    I am currently trying to extend the Event Calendar and having a few headaches with what I am trying to achieve.

    Basically I have a new classes SportEvent and SportEventHolder.

    Each sport event has a category:

    static $db = array(
    'Category' => "Enum('International, National, Club, Special')",

    I have extended the Sport holder filter to allow filitering on this:

    public function getFilterFields()
    $fields = parent::getFilterFields();
    $fields->addFilterField(new DropdownField('SportEvent_Category','Category', singleton('SportEvent')->dbObject('Category')->enumValues()));
    return $fields;

    Now the thing I am having trouble with is figuring out a way I can have the category filter as optional. Is there any way to add 'All' to the drop down box and effectively have it ignore the second part of the filter?

    One way of trying to get around it was removing the filter and having buttons for the categories, with them linked the calendar page with ?filter=1&filter_SortEvent_Category=Club added to the end of the url, but this only works if the user selects the category and then filters on date, not the other was around.

    Any ideas would be much appreaciated. As you can probably guess I am developing the website for my work. We are the governing body of a sport and are wanting to display our official calendar in a much more user friendly way than our current website.

  • UncleCheese
    4085 Posts

    Re: Event Calendar filter troubles Link to this post

    It's been a while since I've been in that code, but I think this might work:

    $fields->addFilterField($d = new DropdownField('SportEvent_Category','Category', singleton('SportEvent')->dbObject('Category')->enumValues()));

    $d->setEmptyString('-- All --');

  • Eric26
    Community Member
    2 Posts

    Re: Event Calendar filter troubles Link to this post

    Perfect, thank you very much.

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.