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 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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

[solved] Question about custom page type setup

Go to End

10 Posts   3490 Views


Community Member, 55 Posts

4 March 2015 at 2:22pm

I've succesfully implemented my own theme into SilverStripe and I am trying to find out how $Layout works.

Suppose I have in my template folder with the following


A as follows template_name/Templates/Layout/

I am any other page than the homepage!

A as follows: template_name/Templates/Layout/

I am the homepage!

I assumed that when you have a file named "" in the Layout folder, this will always be the rendered page (on the spot of $Layout in the main when visiting the homepage of the site. But when opening my site, the Layout/ is always rendered. Was my assumption incorrect?


Community Member, 12 Posts

4 March 2015 at 2:33pm

Have you done a ?flush=all ?


Community Member, 55 Posts

4 March 2015 at 2:36pm

I've tried that already, no change. Thanks for the suggestion though


Community Member, 12 Posts

4 March 2015 at 2:37pm

Is your home page set to the page type of HomePage?


Community Member, 55 Posts

4 March 2015 at 2:41pm

No it is not! The only choices I have in the settings page are:

  • Virtual page
  • Error page
  • Page
  • Redirector page


Community Member, 349 Posts

5 March 2015 at 12:46am

Edited: 05/03/2015 12:49am

1. Add this code to mysite/code folder to file named HomePage.php

 * Defines the HomePage page type
class HomePage extends Page {
   static $db = array(
   static $has_one = array(
class HomePage_Controller extends Page_Controller {

2. After this use -
3. change the pagetype to homepage and save publish
4. to renew the design code.

Arvixe Web Hosting / SilverStripe Community Liaison | Looking for quality SilverStripe Web Hosting? Look no further than Arvixe Web Hosting!


Community Member, 55 Posts

5 March 2015 at 1:38am

Edited: 05/03/2015 2:00am

I changed to HomePage.php and performed all steps. Unfortunately the page type "Home" still isn't available.

edit: I'm using SilverStripe 3.1

edit 2: I've just watched the video related to this issue (setting up custom page type) and it seems that the person in the video is has his website folder in the silverstripe root folder whereas I have it placed in the theme folder (themes/my_own_theme/templates/layouts/ Is this why I can't set up a new pagetype?

The video:


Community Member, 28 Posts

5 March 2015 at 2:00am

Edited: 05/03/2015 2:02am

I think here Tutorial #1 will help you understand much more.
(There's a deprecation warning at the top of the page, but ignore that. It's still very relevant.)

Basically page types are defined in PHP.
Pages use templates to render, based on their classname.
Your initial assumption is correct, however the page type must match the template type.

Basically there are 3 files at play here.
mysite/code/Homepage.php - class HomePage extends Page (along with a matching controller)
themes/yourtheme/templates/ - header, $Layout, footer)
themes/yourtheme/templates/Layout/ - Used as contents of $Layout - filename must match classname(.ss)

Go to Top