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   962 Views

Avatar
Anonymous user

Community Member, 5 Posts

31 August 2011 at 8:00am

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

Forum Moderator, 1132 Posts

31 August 2011 at 8:20am

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

Community Member, 5 Posts

31 August 2011 at 11:33am

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

Forum Moderator, 1132 Posts

31 August 2011 at 9:28pm

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

Community Member, 5 Posts

31 August 2011 at 9:52pm

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

Community Member, 94 Posts

31 August 2011 at 11:38pm

Hi,

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

Avatar
martimiz

Forum Moderator, 1132 Posts

1 September 2011 at 12:29am

Edited: 01/09/2011 12:30am

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

Community Member, 5 Posts

1 September 2011 at 2:25am

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.