The Page Bakery! © 2012 alex schenkel

Writing Layouts

In the standard case, you will write one layout file, but multiple page content files: The idea behind the layouts is the shared design of every page, so you can concentrate on the content instead. In theory, a site can have multiple layouts, e.g. an introduction page can have another look-and-feel than the rest of the layout.

Each layout is defined as Smarty template and is stored in pages/[layout-name].html. The default layout for a page, if not specified otherwise, is layout, and so a corresponding pages/layout.html file must be present. If a page must use another layout, you just set the layout parameter in the doc_config.php for that specific page.

A layout example

A simple layout can look as follows:
<!DOCTYPE html>
<html>
<head>
	<title>{$page.title} - Simple Page</title>
</head>
<body>
	<div class="Menu">
		{foreach $pages as $pageKey=>$pageItem}
          <a href="{$pageItem.link}">{$pageItem.title|escape:html}</a>
        {/foreach}
	</div>

	<div id="content">
		{$page_content}
	</div>
</body>
</html>

This example aready defines a dynamic page title, a link menu to all available pages and a placeholder for the actual page's content.

Please refer to the Writing Pages section for more on template variables, or continue on the Pages section.

© 2012 alexi.ch
Version 1.0 | 2012-10-13