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.

Archive /

Our old forums are still available as a read-only archive.

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

Templating Question


Go to End


2 Posts   1234 Views

Avatar
Blackdog

Community Member, 156 Posts

14 April 2008 at 3:03pm

Edited: 14/04/2008 3:05pm

I am setting up a site which effectively splits off into 2 sub sites.

HOMEPAGE
Section 1
- Some Page
- Some Other Page
Section 2
- Some Page
- Some Other Page

My problem is I wish for each section to use a seperate master template. It is so I can vary the css and javascript between them.

At the moment it works fine for Level 2 ( Section 1 & 2 ) but as soon as I move down into Level 3 it reverts back to using the Page.ss template, am I missing something?

cheers

Avatar
mikehenrty

Community Member, 2 Posts

17 April 2008 at 10:36am

Hmm, what is your inheritance structure?

I was thinking that Homepage is of type Page. Then you have two Page subclasses, something like "class Section1 extends Page" and "class Section2 extends Page." And then your master templates for those sections would be Section1.ss and Section2.ss. If this is what you have, make sure your level three pages are of Section1/Section2 page type, or a subclass thereof. Also make sure your two master templates are in every level of your template folders (i.e. template, templates/Layout, etc)

Also, you can force you level 3 pages to render with particular templates using the page controller with something like this:

return $this->renderWith(array('SomePageSection2', 'Section2'));

So, it will look for SomePageSection2.ss and then Section2.ss to try and render the page with.

Does this help? If not, what is you template folder structure?

Cheers.
Mike