Jump to:

23491 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Using a different template for a page (can't get it to work)

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 691 Views
  • TF-35Lightning
    Avatar
    Community Member
    137 Posts

    Using a different template for a page (can't get it to work) Link to this post

    HI all,
    I am following along the tutorial over at:
    http://doc.silverstripe.org/doku.php?id=tutorial:1-building-a-basic-site#templates

    And it shows you to create an alternate template for a site you must:

    Create a new file HomePage.php in mysite/code. Copy the following code into it:

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

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

    }

    class HomePage_Controller extends Page_Controller {
       
    }
    ?>

    And customise that to suit. It then says
    After building the database, we can change the page type of the homepage in the CMS, under the “Behaviour” tab. Change it to HomePage, and click “Save Draft” and “Publish”.

    Now I have flushed, clearned out my cache, refreshed my browser but still I simply can not get HomePage.php to appear from the page type list.

    Any help would be great

  • SSadmin
    Avatar
    Community Member
    90 Posts

    Re: Using a different template for a page (can't get it to work) Link to this post

    Did you create a HomePage.ss file under template folder or layout folder.

    The ssview render system will find the .ss file in template folder with the same name of your backend php code in mysite/code.

    So you should make sure, you have created a HomePage.php. under mysite/code.
    a HomePage.ss (be carefull the it's case sensitive) under themes/yourthemename/template.
    Do rebuild database command and do ?flush=1

    hope it helps.

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