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.

Installing SilverStripe

Getting SilverStripe up and running on your computer and on your web server.

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

Setting a new page style


Reply

8 Posts   919 Views

Avatar
Anonymous user

31 August 2011 at 8:00am Community Member, 5 Posts

Hi,

Where do I set a new page style in order to be able to see it at the behavior page stye combo box? I've a custom HomePage.ss but I need to apply that page style to my home page.

Thanks

Avatar
martimiz

31 August 2011 at 8:20am Forum Moderator, 1091 Posts

Besides the HomePage.ss template, you need a HomePage.php PageType file. Even an empty class is enough:

<?php
class HomePage extends Page {
}
class HomePage_Controller extends Page_Controller {
}

Once you do a /dev/build/?flush=1, the new pagetype should be available in the create dropdown (top left) as well as the behavior page stye combo box.

Avatar
Anonymous user

31 August 2011 at 11:33am Community Member, 5 Posts

right, I do have a HomePage.php file with that empty class at /www/mysite/code and I did also a database rebuild as suggested, but still no "homepage" at the Page Type options :( any extra ideas?

Avatar
martimiz

31 August 2011 at 9:28pm Forum Moderator, 1091 Posts

Adding the empty HomePage class file and doing a /dev/build/?flush=1, then reloading the admin section should be enough. I have had problems with it every once in a while, but they were always my fault:

- forgot to add <?php at the top of the file (stupid haste)
- spelling errors: the classname not equal to the filename (case-sensitive!)

One other thing may be viewing permissions - but never if you're logged in as admin...

Avatar
Anonymous user

31 August 2011 at 9:52pm Community Member, 5 Posts

I don't think I've forgotten anything...and this file is already working on another website.

<?php
/**
* Defines the HomePage page type
*/

class HomePage extends Page {
static $db = array(
);
static $has_one = array(
);
}

class HomePage_Controller extends Page_Controller {

}
?>

Avatar
bartvanirsel

31 August 2011 at 11:38pm Community Member, 94 Posts

Hi,

maybe removing ?> should do the trick?
When there are empty lines under ?> it might go wrong.

Avatar
martimiz

1 September 2011 at 12:29am (Last edited: 1 September 2011 12:30am), Forum Moderator, 1091 Posts

To find out if the HomePage is at all found properly, You could check the 'manifest' file in the silverstripe-cache directory: it should have something like:

'homepage' => '/some/fysical/path/mysite/code/HomePage.php'

If not, in some weird cases just emptying the silverstripe-cache directory helps...

Avatar
Anonymous user

1 September 2011 at 2:25am Community Member, 5 Posts

Thanks guys, I was able to finally add the "homepage" pagetype in the create dropdown (top left) as well as the behavior page stye combo box.
I had to delete all blank spaces at HomePage.php , rebuild, delete the original Home page at the content management, and create a new one otherwise I could not apply the page type to the already created content. So it looks like it was a cache issue.