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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

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

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

different template per page


Go to End


5 Posts   1607 Views

Avatar
itlinux

Community Member, 40 Posts

22 November 2008 at 11:57am

Hello I wonder if there is a way to have a separate template per page or category

Thanks

Avatar
Nivanka

Community Member, 400 Posts

22 November 2008 at 2:16pm

this can be done easily, create different page types,

lets say my page type is DefaultPage so I am going to save my page in the /mysite/code folder

now to have a separate leyout from the others I am creating a new template for the DefaultPage and save it as DefaultPage.ss in the /mysite/templates folder.

Then when the site is being retrieved the DefaultPages are viewed with that Default.ss file you created not with the /themes/<your theme>/templates/Page.ss

Avatar
itlinux

Community Member, 40 Posts

23 November 2008 at 5:18am

Thanks, where do you set the page type.

Avatar
Liam

Community Member, 470 Posts

23 November 2008 at 8:47am

Generally in the mysite/code/ directory.

I'd suggest reading the tutorial which gives an introduction to this:

http://doc.silverstripe.com/doku.php?id=tutorial:2-extending-a-basic-site

Avatar
Willr

Forum Moderator, 5523 Posts

24 November 2008 at 6:15pm

An upcoming feature in 2.4 will be the ability to select a custom template without a page type which will be quite handy for those pages which don't 'need' any custom code just a separate template. There is a ticket on open.silverstripe.com for this.