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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Themes /

Discuss SilverStripe Themes.

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

$Layout is empty


Go to End


6 Posts   2834 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
bummzack

Community Member, 904 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
bummzack

Community Member, 904 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: 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

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