Not recognising new Page Types

Tags: #<Tag:0x00007f10c741f3c8> #<Tag:0x00007f10c741f288>


Silverstripe Version: 4.3


I am following the tutorials for creating a new page type. I have followed the steps in and I have done a dev/build, but it is not recognising that there is a new page type there.

Am I missing something?


Can you please post the code for your new page type?




namespace SilverStripe\Lesson {

use Page;    

class HomePage extends Page 




namespace SilverStripe\Lesson {

use PageController;    

class HomePageController extends PageController 



You’ve got an extra set of curly brackets in there, as far as I know that’s not valid and should just be:


namespace SilverStripe\Lesson;

use Page;    

class HomePage extends Page 



I have tried both ways and it hasn’t worked either way! I don’t get an error it just doesn’t seem to find it!


That syntax should be fine, you can specify namespaces with curly brackets.


Could you clarify what you mean here? Is it that the page type doesn’t show up in the CMS?


Maybe try:
extends \Page …


Certainly. I have created the PHP files in the correct location and done the /dev/build?flush=all the training document states that I should get some blue text that says there has been a change to Site Tree, I don’t get that.

It also says that I should be able to edit my home page and change the type to my new Home Page type, but it’s not in the list.


So this is weird. I tried your suggestion, no change. It made me think that the build wasn’t looking in there. So I put some out of context text in one of the files and tried again and it crashed. This was good because at least I knew it was looking in there.

I took the text out and reran dev/build. No change to the output, BUT, the new template is now in the page types. I quickly created another page type I needed and it worked properly!

It’s all very weird, but thank you all so much for your help!


I commented just a few minutes ago on that point :slight_smile: The text output doesn’t happen every time, the lessons are a bit misleading in that respect.

Glad it’s working now!


You’ll only tend to get this the first time there was a change. It may not be evident every time you run a dev/build

This is the actual issue. Once the page type has been added, you should see it in the ‘New Page’ dialogue or if you edit a page and choose the page type under ‘Settings’.