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
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
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
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.
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?
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...
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 {
}
?>
Hi,
maybe removing ?> should do the trick?
When there are empty lines under ?> it might go wrong.
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...
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.