Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Themes /

Discuss SilverStripe Themes.

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

Layout not being called for Subtemplates


Reply


3 Posts   1330 Views

Avatar
thenergle

Community Member, 5 Posts

16 March 2011 at 5:19am

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" xml: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?

Avatar
Willr

Forum Moderator, 5513 Posts

16 March 2011 at 5:52pm

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.

Avatar
thenergle

Community Member, 5 Posts

17 March 2011 at 2:17am

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.