Skip to content
Sitemason - Build on Us

What is a Template?

In Sitemason®, a template is the file (or set of files) that translates the data contained in Sitemason into a working website - the template defines that website's design and layout and presents the data to the end user  There are two types of templates in Sitemason: Site Templates and Tool Templates.  While each Sitemason website will use one or two Site Templates (always one production template and sometimes one development template), the use of Tool Templates is optional.  It's helpful to discuss these in reverse order.

Tool Templates

A Tool Template is the layout used by each Sitemason Tool.  A good example is a typical news page that features a list of articles (the list view) with each article possibly having a title, subtitle, thumbnail, and summary.  The user then clicks on a title to access the full article (the detail view), which contains most of the same information found in the list view along with the full article and additional details.  Sitemason's News Tool is the logical choice to implement such a news page.  And the HTML used to construct the list and detail views is called the Tool Template (in this case, the News Tool's Template).  And just like News has a template, so does Gallery, Page, Store, and every other Sitemason Tool.

Sitemason comes with a pre-defined Tool Template Set (cleverly called "smDefault") that resides in your website's file space and is available for you to use, replace, or modify to your liking.  The Tool Template Set's layout is presented within your Site Template by calling SMTool's printHTML() method.  However, one important thing to keep in mind is: you are not forced to use the Tool Template Set to define the layout for any Tool.  Instead of calling printHTML() on a Tool, you could simply write your own custom HTML to present the data however you want.  The Tool Template Set simply provides a default, commonly-used layout.  Also, the Boilerplate template provides examples of both layout approaches.

Site Templates

The default Tool Template set features a clean layout with no graphics or real design - that's because the purpose of the Tool Template Set is to be contained within a Site Template.  The Site Template is the file, or set of files (via included files), that defines your website's look and feel and provides the logic needed to present the data as you need it.

Another way to think of it is this: think of a website, then remove the chunks of content and replace them with black blocks.  The section containing those blocks is the Site Template.  The data replaced by those blocks is filled with either the layouts from a Tool Template Set or your own custom HTML coded within your Site Template.  We'll discuss Tool Template Sets later on, but next up is more discussion about the Site Template.

The Boilerplate Template

When you sign up for a new Sitemason® account, you are not forced to start from scratch.  As part of the sign up process, your accounts is automatically loaded with a working website to serve as an example.  In fact, you can take a look immediately after signing up by visiting:

http://www.example.com.sitemason.com

Your demo website consists of a handful of pre-configured example Tools, which you should feel free to edit, experiment with, ignore, or delete.  And to present the data from these Tools and turn it into a working website, a sample template is also loaded into your account.  We call this the Boilerplate Template.

The Boilerplate Template is a full-fledged working Sitemason template that you are free to use however you see fit.  It is a fairly comprehensive example and we've tried to comment it very well to explain everything that is going on code-wise.  You can use it as-is, though some parts have been specially coded to work with the sample Tools placed into your account.

If you want to take a look right away, log into your account's file space via FTP and look under the ~/www/smTemplate folder (note: if you set up a host name other than "www," look in that folder).  We'll discuss the locations of everything in the File Locations section.

Sitemason Development Library

A Site Template is nothing more than a static website if you cannot access the data stored in Sitemason®.  For that, you'll use the Sitemason Development Library, which translates your site's data (residing in Sitemason) into objects that your Site Template can use.  The Development Library is loaded before the server loads your Site Template, so it's automatically available and ready to use in your Site Template.

So, to review the process: first you enter and manage your website's data in Sitemason.  Then when someone visits your website:

  1. The Development Library translates your data into PHP objects.
  2. Your Site Template presents the data in those objects either directly or via a Tool Template Set.

The next section will discuss the Development Library in more detail.