Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Using a different template for the home page

Our old forums are still available as a read-only archive.

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

Page: 1 2
Go to End
Author Topic: 32265 Views
  • bcm75204
    Avatar
    Community Member
    6 Posts

    Using a different template for the home page Link to this post

    I went through the "Using a different template for the home page" section of the tutorial several times and I cannot get this to work. I want my home page to have a different layout than the rest of the site. I did multiple flushes and nothing changed. Any suggestions?

    Thank you.

  • trevor
    Avatar
    53 Posts

    Re: Using a different template for the home page Link to this post

    Hi,

    One thing you could check is did you also change the page type for the home page in the cms?

    If you followed the tutorial exactly then it should work.

    Regards

    Trevor

  • bcm75204
    Avatar
    Community Member
    6 Posts

    Re: Using a different template for the home page Link to this post

    The option to change it does not appear in the dropdown in the cms. Anybody else having this problem?

    Thanks.

  • bcm75204
    Avatar
    Community Member
    6 Posts

    Re: Using a different template for the home page Link to this post

    Can somebody tell me which folder HomePage.ss goes into?

    Is it /public_html/themes/blackcandy/templates/?

    or /public_html/themes/blackcandy/templates/Layout/

    Thanks.

  • quicked
    Avatar
    Community Member
    32 Posts

    Re: Using a different template for the home page Link to this post

    If your HomePage is completely different put the template directly under templates/
    If it is based on Page.ss then put it under templates/Layouts.
    You will need a file called HomePage.php in mysite/code and you will need to select that page type in the CMS.
    To refresh hold down ctrl and add ?flush=1 to the URL. Sometimes i have had to change browsers to see a change reflected.

  • bcm75204
    Avatar
    Community Member
    6 Posts

    Re: Using a different template for the home page Link to this post

    It still doesn't work. The option to create a home page does not appear in the dropdown option in the CMS. Anybody out there know how to use this?

  • quicked
    Avatar
    Community Member
    32 Posts

    Re: Using a different template for the home page Link to this post

    Somebody correct me if I am wrong, but if you create a file called WhateverPage.php in mysite/code then db/build/?flush=1 (do it in the CMS), then 'Create a WhateverPage' has to appear in the drop down for create page type. If not, something is very wrong. It seems to be it is practically the premise for the whole system. What options appear in your dropdown?

  • DesignCity
    Avatar
    38 Posts

    Re: Using a different template for the home page Link to this post

    bcm75204 - check the tutorials more carefully (http://doc.silverstripe.com/doku.php?id=tutorial:1-building-a-basic-site#using_a_different_template_for_the_home_page) - If you follow them it will show you how to add pagetypes to the CMS. How you then style them depends on the template that is used for the site.

    Given I don't know much of your setup, here's how I think you would add a home page:

    1. Add HomePage.php to /mysite/code/ (with the same code as listed under http://doc.silverstripe.com/doku.php?id=tutorial:1-building-a-basic-site#creating_a_new_page_type)

    2. If you want the home page to be COMPLETELY different, add a template file called HomePage.ss to /themes/blackcandy/templates/. You can copy and paste the data from Page.ss into it and make any changes you want. If you want to edit the CSS of the design, you can either include a new stylesheet into the page or just make additions to BlackCandy's (found in /themes/blackcandy/css/).

    3. This point in the tutorial is key - "Every page type also has a database table corresponding to it. Every time we modify the database, we need to rebuild it. We can do this by going to http://localhost:3000/db/build?flush=1." You need to flush the database by visiting /db/build and then refresh the CMS (F5) or the new pagetype will not be available.

    32265 Views
Page: 1 2
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.