The Diogenes Manual of (Consistent) Style

Diogenes, like all good content management systems, has the ability to place page and other dynamic content into pre-designed HTML pages. In this way, some or all pages in a barrel can have a consistent appearance, without the web designer needing to copy and paste the same markup into every page.

This page details how to manage templates, from both the site, barrel, and page admin perspectives.

Default Templates

At both the site and barrel levels, it is possible to define which of the available templates will be used by lower-level configurations if they do not specify something different. This is most useful when pages are left with the "default" template, because the look of a whole barrel of pages can be changed by simply defining a new template and picking that as the default template for the barrel -- all pages which use the barrel-default template will immediately start using the new template. Schweet!

Site-level templates

At the site level, the administrator can define where in the system the templates are to be stored, and what the default template will be for every page in the system if not over-ridden at a lower level.

All templates to be used in the system must be placed in the directory specified by the site administrator -- barrel- and page-level administrators cannot add their own templates without the site administrator's approval. This is because templates in Diogenes are written using Smarty, a smart templating engine which allows the embedding of PHP code. Because of this, malicious or poorly written templates can be a security hazard; hence the requirement that only the site administrator can add templates to the Diogenes installation.

Once the template directory has been set up, it can be populated with templates for use by users. This is done by simply writing a template, and placing it in the template directory, ensuring it has a .tpl extension. It will then be selectable in the list of templates.

Barrel-level templates

The barrel administrator can select which template will be used for all pages in the barrel which do not have their own template defined. Selecting <default> will cause the barrel to use the site-default template as it's default.

Page-level templates

The page administrator can select which template will be used for the currently selected page. Selecting <default> will cause the page to use the barrle-level default template.

Writing Templates

Diogenes Templates use the Smarty templating language to define how templates appear. For the most part, a template is just HTML code with some special markers to tell Smarty to insert pieces of HTML into various places in the template. As an example, here is what Diogenes's master template master.tpl looks like. This template is used to display either a nested template ($page_template), a PHP file ($page_include) or a block of HTML code ($page_content).

{include file='header.tpl'}

{if $page_template}{include file=$page_template}{/if}
{if $page_include}{include_php file=$page_include}{/if}
{if $page_content}{$page_content}{/if}

{include file='footer.tpl'}

There is a section of the Smarty manual called "Smarty for Template Designers" which gives copious detail on how to write Smarty templates. There are also a large number of tutorials on how to write templates for Smarty. Finally, you can inspect the examples that come with Diogenes to see what Smarty can do for you.