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.

All other Modules /

Discuss all other Modules here.

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

Events Calendar alternative templates


Reply


4 Posts   772 Views

Avatar
redactuk

Community Member, 117 Posts

15 August 2011 at 4:42am

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?

Avatar
UncleCheese

Forum Moderator, 4096 Posts

16 August 2011 at 1:38am

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

Avatar
redactuk

Community Member, 117 Posts

16 August 2011 at 11:45am

Edited: 16/08/2011 11:48am

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)

Avatar
UncleCheese

Forum Moderator, 4096 Posts

19 August 2011 at 1:47am

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