Jump to:

10845 Posts in 2516 Topics by 1792 members

All other Modules

SilverStripe Forums » All other Modules » Events Calendar alternative templates

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 670 Views
  • redactuk
    Avatar
    Community Member
    115 Posts

    Events Calendar alternative templates Link to this post

    Can anyone give a me a pointer as to how I go about specifying alternative Calendar.ss layouts based on overall calendar?

    I have extended Calendar to add some custom functionality and so I have a custom MyCalendar.ss template. Wnat I want to do is switch between using MyCalendar.ss and MyCalendar2.ss depending on the calendar I'm using. I'm guessing I build a switch based on the overall calendar IR or maybe part of the URL?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Events Calendar alternative templates Link to this post

    Those templates are meant to be overridden. Just place a Calendar.ss, CalendarEvent.ss, etc, in your theme Layout dir.

    ---------------
    Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com

  • redactuk
    Avatar
    Community Member
    115 Posts

    Re: Events Calendar alternative templates Link to this post

    Thanks for the reply UC, but what I meant was how i could best rednder the calendar output to use alternative calendar templates depending on what calendart was being used i.e. i have more than one calendar on the website.

    Anyway I've resolved my problem now by keeing the Calendar.css, but including some conditional includes to determine from calendar is being called (a bit dirty but I hard-coded condition to use using URLSegment)

  • UncleCheese
    Avatar
    4085 Posts

    Re: Events Calendar alternative templates Link to this post

    Ah, yeah.. In SilverStripe it's one template per controller. So to show an alternate layout, between two pages that use the same controller, you have a couple options. If the changes are pretty simple and non-structural, you can class and id the body element.

    <body class="$ClassName" id="$URLSegment">

    If it's more complex, then subclass the two controllers

    AlternateCalendar.php

    AlternateCalendar extends Calendar {}
    AlternateCalendar_Controller extends Calendar_Controller {}

    AlternateCalendarEvent.php

    AlternateCalendarEvent extends CalendarEvent {}
    AlternateCalendarEvent_Controller extends CalendarEvent_Controller {}

    Of course, the naming pattern is up to you, but that will allow you to create AlternateCalendar.ss and AlternateCalendarEvent.ss. Just remember to change the page types in the Behaviour tab.

    --------------------
    SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

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