Jump to:

1382 Posts in 491 Topics by 521 members

Themes

SilverStripe Forums » Themes » Layout not being called for Subtemplates

Discuss SilverStripe Themes.

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

Page: 1
Go to End
Author Topic: 1243 Views
  • thenergle
    Avatar
    Community Member
    5 Posts

    Layout not being called for Subtemplates Link to this post

    I am working on a test theme for a client. He would like to migrate a large number of web sites but isn't sure that SilverStripe is the way to go. This is the first time I have used SilverStripe. Anyway, I've been following along in the Building a Basic Site tutorial on creating the layouts.

    I created my own template by copying the tutorial folder over and for the most part that seemed to work fine. In fact Page.ss works like a charm. But I have pretty much run into a brick wall on the HomePage page-type and layout. I created my HomePage.ss file in templates and it seemed to work alright after awhile. However, I created my layout file and removed the HomePage.ss file and added $Layout to the Page.ss and the only page I can get to work is the Page.ss.

    I created two page types to test the first one is the HomePage:

    Here is the code I have for that:

    <?php
    class HomePage extends Page {

       static $db = array(
       );

       static $has_one = array(
       );

    }
    class HomePage_Controller extends Page_Controller {

    }

    My Page.ss file:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" >
       <head>
          <% base_tag %>
          <link rel="stylesheet" type="text/css" href="tutorial/css/layout.css" />
          <link rel="stylesheet" type="text/css" href="tutorial/css/typography.css" />
          <link rel="stylesheet" type="text/css" href="tutorial/css/form.css" />
       </head>
       <body>
          <div id="Main">
             <% include Header %>
             <div id="ContentContainer">
                $Layout
             </div>
             <% include Footer %>
          </div>
          $SilverStripeNavigator
       </body>
    </html>

    My HomePage.ss file:

    <div id="Content" class="typography">
    $Content
    </div>

    Really basic.

    Anyway, I have done the dev/build?flush=all repeatedly and it is not improving the response. If I have the Page type set as Home Page I receive a completely empty page. No style information in the head and no content or body information.

    I have a MenuPage type which is virtually identical to the HomePage. When I have the Page Type set to Menu Page I actually get content but all the style information is gone and I receive this message: Generated with the default ContentController.ss template.

    Any thoughts as to why the Layout does not appear to be working?

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: Layout not being called for Subtemplates Link to this post

    If you get a blank page for the HomePage it could be a PHP error. Check your PHP / apache error log for more information.

    I have a MenuPage type which is virtually identical to the HomePage. When I have the Page Type set to Menu Page I actually get content but all the style information is gone and I receive this message: Generated with the default ContentController.ss template.

    Does MenuPage extend Page and MenuPage_Controller extend Page_Controller? If it mentions ContentController that would indicate it isn't picking up your Page.ss template.

  • thenergle
    Avatar
    Community Member
    5 Posts

    Re: Layout not being called for Subtemplates Link to this post

    I checked the Error log and there wasn't anything in there. I did look through some of the other forums and found that I did not have a silverstripe-cache folder that was writable. I changed that and it appeared to fix both the blank page and the MenuPage generation message.

    I did have the pages extending Page_Controller. So it seems to be working now.

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