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.

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

Templates not Showing in the CMS


Go to End


11 Posts   5736 Views

Avatar
SmartRoss

Community Member, 13 Posts

7 September 2010 at 7:45am

I think this ought to be in here, as it seems a bit basic for the Templates forum, but sorry if I'm wrong!

I've just started working with this excellent CMS, and am following the tutorials to learn how to get the most out of it. My problem is with creating a new template. I've created a HomePage.php file in /mysite/code, added a Page.ss and HomePage.ss to /themes/tutorial/templates/Layout, and added the $Layout tag to the Page.ss file in /themes/tutorial/templates. I have also flushed the database using ?flush=1, as the tutorial states. However, when I go back into the CMS, the new HomePage template doesn't show up in the list - only the Page template and the other ones that come by default.

I've searched around, and this problem seems to have come up before, but only on 2.3 - I'm running 2.4. Does anybody have any idea what's wrong, or is it something stupid that I've missed, somewhere?

Avatar
Martijn

Community Member, 271 Posts

7 September 2010 at 8:00am

Not sure what you mean with 'Does not show op in the CMS', but in SiteConfig there is only a list with installed themes, not seperate template files.

In the create list in the CMS Left pagetype select dropdown, should be all PageTypes you created.

SS will select the templates based on the PageType classname and the corresponding template filename.

Also you might try to use ?flush=all .

Avatar
SmartRoss

Community Member, 13 Posts

7 September 2010 at 6:34pm

OK, I'll try and explain it a bit better.

When I created a template as per the tutorial, after using ?flush=1, the list of templates does not show the new HomePage template - neither under the Create button on the left, or in the Behaviour tab of any page. I've followed all of the Tutorial instructions, and when it talks about changing the PageType of an existing page, I can't, because the new Template isn't in the list to change it to.

I've just tried ?flush=all, and that doesn't work either.

Avatar
bummzack

Community Member, 904 Posts

7 September 2010 at 8:21pm

You're confusing things here. I think you mean a new "Page-Type" and not a new template. The types you can select in the CMS for creation are "Page-Types".
To make new types available you have to run dev/build

Avatar
SmartRoss

Community Member, 13 Posts

8 September 2010 at 3:20am

OK, I see now. Yes, it is a Page Type that I'm meaning. However, I don't see what you mean by /dev/build - the only dev folder I can find is /sapphire/dev, and it doesn't have any file called build in it. Even so, the tutorial maintains that you use ?flush=1, and that makes it available. Have I missed a /dev folder, or is there some other problem?

Avatar
Martijn

Community Member, 271 Posts

8 September 2010 at 4:01am

Edited: 08/09/2010 4:12am

Running dev/build, recreates the Manifest file which stores Class information from Silverstripe and will rebuild the database.

In order to let Silverstripe know you added a new PageType, you need to rebuild the Manifest file and the database.

You do this by adding dev/build to your site like:

www.example.org/dev/build?flush=all

You will see a blue screen which shows information about which database tables and fields are changed.

See this page for more info:

http://doc.silverstripe.org/urlvariabletools?s[]=dev#building_and_publishing_urls

The dev part is redirected to (sapphire/dev/)DevelopmentAdmin(.php) with Director::addRules() in sapphire/_config.php;

From there the specific task is run.

Yoy can see the available tasks by only appending only /dev to your siteurl.

Avatar
SmartRoss

Community Member, 13 Posts

8 September 2010 at 5:27am

When I enter www.example.org/dev/build?flush=all, I get a 404 Page not Found error, as if the CMS isn't redirecting the request. I also tried directly accessing the file by www.example.org/sapphire/dev/DevelopmentAdmin.php?flush=all, and got a 404 again.

Avatar
Martijn

Community Member, 271 Posts

8 September 2010 at 5:57am

Ehm, you did not really tried example.org?

I mean www.yoursite.org/dev/build

And if you installed in a subfolder something like:

www.yoursite.com/subfolder/dev/build

Make sure you have set Director::set_environment_type("dev"); in you config.php file.

Go to Top