Jump to:

1347 Posts in 439 Topics by 514 members

Themes

SilverStripe Forums » Themes » $Layout is empty

Discuss SilverStripe Themes.

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

Page: 1
Go to End
Author Topic: 1491 Views
  • chris.poirier
    Avatar
    Community Member
    6 Posts

    $Layout is empty Link to this post

    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>

    ...

  • banal
    Avatar
    Community Member
    901 Posts

    Re: $Layout is empty Link to this post

    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.

  • chris.poirier
    Avatar
    Community Member
    6 Posts

    Re: $Layout is empty Link to this post

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

  • banal
    Avatar
    Community Member
    901 Posts

    Re: $Layout is empty Link to this post

    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');

  • chris.poirier
    Avatar
    Community Member
    6 Posts

    Re: $Layout is empty Link to this post

    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: http://sunfresh.digitalglyptics.ca

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

    404: http://sunfresh.digitalglyptics.ca/fff/
    login: http://sunfresh.digitalglyptics.ca/Security/login

  • chris.poirier
    Avatar
    Community Member
    6 Posts

    Re: $Layout is empty Link to this post

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

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