The Page Bakery! © 2012 alex schenkel

Writing Pages

The Page bakery knows 3 levels of hierarchy:

  • Layouts define the global skeleton or design of a page. In the standard case, a Page Bakery site just contains 1 layout with multiple pages.
  • A Page is part of a layout, which forms a whole web page together. The page fills the layout with content, and can contail multiple sub-pages.
  • A page can contain multiple sub-pages, e.g. it can define a sub-menu which splits the page into smaller parts.

All layouts, pages and subpages are represented by a Smarty-Template. Each template is stored as an HTML file in pages/page-name.html and can use all the template mechanisms known by Smarty. The available Smarty template variables can be found below.

3 Steps to a page

Step 1: Write a layout

See section Layouts for detailed instructions. In short: A layout is a file in pages/ which contains the layout code and includes the actual body's content at one point.

Step 2: Configure the page

Each page contains an entry in the pages entry in doc_config.php. A simple page can be defined as follows:
Config::set('pages',array(
	'index' => array('title' => 'Overview','iconCls'=> 'icon-home','layout'=>'layout')
	)
);
This defines the page index with some attributes. The attributes can be defined as you need them: You have access to those attributes in the template. There are only 3 attributes that are system-dependant:
  • layout: If set, the defined layout file is used. Defaults to 'layout' (and thus, pages/layout.html as a template).
  • subpages: an array defining subpages. More on this topic can be found in the Subpages section.
  • defaultSubpage: Defines the default subpage to be shown.

Step 4: Write the page!

Which is described in the Pages section.

Template variables

All templates, including the layout template, know the following Smarty-assigned variables, which can be used within the layouts/pages/subpages template files to add some logic:
Variable nameDescriptionTemplate Usage Example
$pages Contains the 'pages' configuration array, enhanced with the actual pages links,
which are either dynamic links for online-use or the link to a static html file when the page was being built for static usage.
Please refer to page 
<a href="{$pages.usage.link}">Usage</a>
$config Contains the whole Configuration as defined in doc_config.php, unmodified.
Page dir: {$config.pageDir}
$defaultPage Contains the default page configuration array Same as one entry in $pages. The $defaultPage variable is always set, except an error occurs. The default page can be set by using Config::set('defaultPage','page-key');, and, if not set, defaults to index.
Back to <a href="{$defaultPage.link}">Home</a>
$page_key Contains the page key as defined in the 'pages' array of the actual page. Useful for e.g. check if you are on a certain page: Highlight actual page's menu entry, for example.
{if $page_key == 'index'}Welcome Home!{/if}
$sub_key Contains the sub-page key as defined in the 'subpages' array of the actual page. Useful for example to check if a sub-page is selected or not.
{if $sub_key}{$subpage_content}{/if}
$sub_key Contains the sub-page key as defined in the 'subpages' array of the actual page. Useful for example to check if a sub-page is selected or not.
{if $sub_key}{$subpage_content}{/if}
$page Contains the actual page's config array, including calculated link.
Page title: {$page.title}
$sub If a subpage within a page is defined and requested, $sub contains the actual subpage's config array.
{if $sub_key}You are on sub-page {$sub.title}.
$page_content Contains the actual page's content. Only useful in layouts where you want the actual page's content to be displayed.
<html>
  <body>
    <div>Page: {$page.title}</div>
    <div>{$page_content}</div>
  </body>
</html>
$subpage_content Same as the page_content variable, but contains the SUB-page content of an actual page. Only useful in pages which contain sub-pages.
Page: {$page.title}<br />{$subpage_content}
© 2012 alexi.ch
Version 1.0 | 2012-10-13