Jump to:

4913 Posts in 7042 Topics by 1474 members

Installing SilverStripe

SilverStripe Forums » Installing SilverStripe » Setting a new page style

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

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

Page: 1
Go to End
Author Topic: 792 Views
  • Anonymous user
    Avatar
    Community Member
    5 Posts

    Setting a new page style Link to this post

    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

  • martimiz
    Avatar
    Forum Moderator
    1035 Posts

    Re: Setting a new page style Link to this post

    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.

  • Anonymous user
    Avatar
    Community Member
    5 Posts

    Re: Setting a new page style Link to this post

    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?

  • martimiz
    Avatar
    Forum Moderator
    1035 Posts

    Re: Setting a new page style Link to this post

    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...

  • Anonymous user
    Avatar
    Community Member
    5 Posts

    Re: Setting a new page style Link to this post

    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 {

    }
    ?>

  • bartvanirsel
    Avatar
    Community Member
    88 Posts

    Re: Setting a new page style Link to this post

    Hi,

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

  • martimiz
    Avatar
    Forum Moderator
    1035 Posts

    Re: Setting a new page style Link to this post

    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...

  • Anonymous user
    Avatar
    Community Member
    5 Posts

    Re: Setting a new page style Link to this post

    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.

    792 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.