Example Layouts

Example Blog Layout

This is an example of how you could make a layout for a blog page containing a posts module and a sidebar.

First, create a layout file in the template folder, e.g. layouts/blog.php. This file will be rendered when a page with a Blog layout is displayed.

Example layouts/blog.php

<?php
/*
  type: layout
  content_type: dynamic
  name: Blog
*/
?>
<?php include template_dir().'header.php'; ?>
<div class="container">
    <div class="blog-content edit" field="content" rel="content">
        <h2>Recent Posts:</h2>
        <module type="posts" />
    </div>
    <div class="blog-sidebar edit" field="sidebar" rel="inherit">
        <h2>Categories</h2>
        <module type="categories" />
    </div>
</div>
<?php include template_dir().'footer.php';

Creating Post Layout

A blog layout should also have an inner page to show single posts. You could store the layout in layouts/blog_inner.php. Another option is to keep it in the template root folder and use it as a default layout for posts in all pages. Editable regions and a comments module would seem appropriate for such layout.

Example layouts/blog_inner.php

Example Shop Layout

If we want to have a shop pages in out template we will need to make a shop layout and a layout to display products from the shop.

The shop layout is created by including is_shop property in the definition of the layout file. You can add products only to pages that are defined as shop by using a shop layout.

Make a new file at userfiles/templates/my_template/layouts/shop.php, this file will load when you create new page and choose the "Shop" layout.

Example shop.php

The categories, shop/products and shop/cart modules are now rendered by the layout.

Product

Example layouts/shop_inner.php

Example Contact Form Layout

Example layouts/contacts.php

Last updated

Was this helpful?