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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

can you clear this up for silverstripe noob?


Go to End


2 Posts   1743 Views

Avatar
natron

Community Member, 3 Posts

29 September 2009 at 3:59pm

Currently i have one template .ss file named 'Page.ss.' This is the first basic page template I've made by converting my html.
It's a basic two column page.

I just installed the calendar module and it's running fine but it appears to be based on "Page.ss" or at least the two columns from "Page.ss" are still present resulting in three columns when the calendar is viewed.

I'd like to disregard 'Page.ss' when viewing the calendar page. Is this possible? I was under the impression that the .ss files were templates for pages and assigned to actual pages in the cms. Seems to me that the calendar is somehow being forced into the 'Page.ss' template...

probably missing something obvious here.. but no clue at this point!

Avatar
UncleCheese

Forum Moderator, 4102 Posts

29 September 2009 at 5:22pm

Each template is composed of at least two parts -- the main template, and the layout.

In the root of your templates/ directory, you'll have a Page.ss. This is the main "wrapper" for your site, that is, all the elements that essentially never change from page to page. On this site, the Page.ss probably ends after the grey strip under the main nav, for instance.

In the Layout/ subfolder, you can define custom templates for each of the page types. A Calendar page will use Calendar.ss, for instance.

However, these templates all use inheritance and overrides to make the design fully customizable for you. For instance, if your calendar page requires its own wrapper for some reason -- maybe it looks totally different than the rest of the site -- you can create Calendar.ss in the root templates/ directory and include the doctype, main nav, etc as part of that template.

The template parser (SSViewer) will also "fall back" on the most logical choice for a template if one is not found. If you have a Calendar page type and no Layout/Calendar.ss exists, it will fall back on Layout/Page.ss because the Calendar object is a subclass of Page.

Further, if you have a module installed, e.g. EventCalendar, SSViewer will always look in your theme directory first for the template, and then fallback on the module. To create a custom template for EventCalendar, for instance, you would copy the file /event_calendar/templates/Layout/Calendar.ss to /your_theme_dir/templates/Layout and make the changes you want. That way, you can safely upgrade the module when new releases come out and have the peace of mind that you have insulated all of your customizations.