Templates

Each blueprint has at least one template (and usually more) that give you access to that blueprint's data. For the news blueprint, for example, there's an index template giving access to all news posts for the page paginated in groups of ten; an archive template to see all posts for the page; a post template (which is a view on any single post) and feed, an atom-formatted feed of recently published posts.

When you install a blueprint for a site, a folder is created in your site's blueprints folder containing the default templates for that blueprint:

nws

The default templates for core blueprints are increasingly well-documented with comments and example code, so it's worth installing and exploring them to see what they're capable of.

Different Views of the Same Data

By default, blueprints have a template for each action in their controller (an action, very loosely speaking, is a structured database query providing content for the corresponding view). Here's a snippet of controller code from the News blueprint:

news_controller

Don't worry too much if that doesn't mean much to you! It simply illustrates the concept of an 'action'.

You can create additional templates that treat the same data in different ways.

By way of example, it's likely that in lots of cases your home page needs to look or behave differently from a standard page in your site. To achieve this, you would create a new template called home.index.html.erb and insert your alternative template content.

There are naming conventions for alternative templates that it's important to understand.

Default action templates are named like this:

action.render_type.renderer (eg: index.html.erb)

(Note: if the action doesn't exist, an empty (action_missing) action will be used, and the action will be treated as the template name.)

An alternative template for a given action would be named like this:

template.action.render_type.renderer (eg: home.index.html.erb)

You can select which template applies to a given page from within the Structure tab:

customtemplates

User notes

(You can add notes to this page using the form below.)


Only the note field is required.

Preview or