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 is empty


Reply


6 Posts   1688 Views

Avatar
chris.poirier

Community Member, 6 Posts

4 September 2009 at 6:25pm

I am setting up my first Silver Stripe site after doing the tutorials, and the Layouts are not working for me. I have a Page.ss and Layout/Page.ss, and I am using $Layout to include the layout in the main template. When I go to a Page, there is no HTML coming through from the Layout file. I cannot find any differences between the tutorial and my code.

Can anyone help me?

mysite/code/Page.php:

<?php
class Page extends SiteTree {
   public static $db = array(
   );
   public static $has_one = array(
   );
}
class Page_Controller extends ContentController {
   public function init() {
      parent::init();
   }
}
?>

themes/sunfresh/templates/Page.ss:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

      <% base_tag %>
      <title><% if MetaTitle %>$MetaTitle<% else %>$Title<% end_if %> &raquo; Your Site Name</title>
      $MetaTags(false)
      <link rel="shortcut icon" href="/favicon.ico" />
      
      
   ...

   </head>
<body>

<div id="container">
   <div id="header">
      <div id="topmenu">
         <% include Navigation %>
      </div>
   </div>
   <div id="menu_bg">
<div id="menu">
         <% include Menu %>
      </div>
   </div>
   <div id="holder">
      $Layout
   </div>

   <div class="clearfooter"></div>
</div>   

<div id="footer">
   <% include Footer %>
</div>

</body>
</html>

themes/sunfresh/templates/Layout/Page.ss:

<div id="content">
   $Content
</div>
<div id="submenu">
   <% include SubMenu %>
</div>

View Source:

...

</div>
<div id="holder">      
</div>
<div class="clearfooter"></div>

...

Avatar
banal

Community Member, 901 Posts

4 September 2009 at 7:31pm

Hi and welcome to SilverStripe

Did you flush the cache of the page by appending ?flush=1 to the URL? This is necessary when you add layout files or includes.

Avatar
chris.poirier

Community Member, 6 Posts

4 September 2009 at 7:45pm

I put ?flush=1 at the end of the url, and went to the /dev/build/?flush=1 for good measure.

Avatar
banal

Community Member, 901 Posts

4 September 2009 at 9:30pm

To no avail? That's really strange. Your code looks fine to me.
Maybe also try to clear the browser cache, although it's unlikely that this is causing the problem...
You did set the theme to 'sunfresh', right?

// put this in your mysite/_config.php
SSViewer::set_theme('sunfresh');

Avatar
chris.poirier

Community Member, 6 Posts

5 September 2009 at 5:56am

Edited: 05/09/2009 6:02am

Yeah, I found it strange too.

I've tried different browsers on different computers, and it definitely is using the 'sunfresh' theme.

The site is located here: [url]http://sunfresh.digitalglyptics.ca[/url]

Update:
Here's something I just noticed, the 404 page and Security/login page both work with the Layout.

404: [url]http://sunfresh.digitalglyptics.ca/fff/[/url]
login: [url]http://sunfresh.digitalglyptics.ca/Security/login[/url]

Avatar
chris.poirier

Community Member, 6 Posts

7 September 2009 at 1:00pm

I fixed the problem. I had mistakenly ended a control block in Includes/Menu.ss with <% end_if %> instead of <% end_control %>.