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.

Template Questions /

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

Using multiple unique templates


Go to End


3 Posts   1551 Views

Avatar
karnh

Community Member, 10 Posts

11 September 2015 at 2:12pm

Hi
I was wondering if anyone could help with this. We are wanting to use multiple templates for our SS CMS for various projects (as described below). We are also wanting to have several add-ons within the CMS but would like all of the projects to have access to them.

Master template
Project 1: elements of master template + own unique design e.g. red background, different navigation links
Project 2: elements of master template + own unique design e.g. blue background, different navigation links
Project 3: elements of master template + own unique design e.g. grey background, different navigation links

We were wondering what the best implementation method is? My thoughts about this are: Would we need to have a master template and then various projects inheriting master template elements plus their own design? Or would it be best to use separate projects for each template?

Any ideas would be greatly appreciated.

Cheers
Karn

Avatar
helenclarko

Community Member, 166 Posts

11 September 2015 at 3:06pm

Hi Karnh,

Maybe subsites?

https://github.com/silverstripe/silverstripe-subsites/tree/master

You will need to load alternate CSS files for each project, but this add-on should do the trick.

-helenclarko

Avatar
Feejin

Community Member, 4 Posts

1 October 2015 at 11:20pm

Edited: 01/10/2015 11:21pm

Are these separate domains or all within one website? If it's the latter you could achieve it by having a separate holder (home page) for each project and then use that as a hook for branding. For example, your site tree might be something like this:

Project 1 Holder
 -- Subpages
Project 2 Holder
 -- Subpages
Project 3 Holder
 -- Subpages

Then you could have:

<body class="{$ClassName}">

Which might come out like:

<body class="project1Holder">

And your CSS can use this to override branding on a per project basis:

.project1Holder {
  .somestyles {
    color: red;
  }
}

If you use a pre-processor (LESS, SASS, SCSS, Stylus etc) then you can take advantage of mixins to make this easier.

However if they are more separate than this, the subsites module Helen mentioned is probably a better bet.