Helix:Templates

From HelixCore

Jump to: navigation, search

Contents

Prior to Helix 0.8.6

Prior to Helix version 0.8.6, templates were managed using a single site variable,

$site->defaultTemplate	=	"default";

Where 'default' is the directory in /core/templates that should contain an index.php file.

Helix 0.8.6 and Beyond

With Helix version 0.8.6 the templates changed to a new category based system. You MUST define a default template, and you can optionally define a default template for other sections of the site, such as administration or the directory.

Some parts of the site, for example, the directory, will call upon multiple categories, for example, a "Directory Category" page will use the template default by default, it will then check if a "directory" template has been defined and if so, it will use that. It will then check if a "category" template has been defined and if so, use that instead of the directory template. This allows you to not only define templates for sections of the site, but also subsections, without the need to set every page to the template of your choosing.

Site sections are defined by the component, custom components can make calls to the template handler to ask for any section name, even an undefined or custom section name.

To configure default templates, remove any calls to $site->defaultTemplate in your config, then add the code, if it doesn't already exist:

$site->templates = array( "default" => "default", // Normal pages, default
	"admin"		=> "default", 			// Admin pages
	"billing"	=> "default", 			// Billing pages
	"invoice"	=> "default.html"	);	// Invoices

This defines a list of sections, and their respective templates in an associative array. Other sections that core components will check for are: ssl, error, directory, master, category.

"ssl" is used by secure pages. "error" is called for when an error condition, such as a 404 or 500 occurs. "directory", "master" and "category" apply to the directory system, directory is call by all areas, master and category are called by the directory master pages (directory home page) and category pages respectively.

To Define Template Sections

To define the section your component should call for, simply make this call at the top of your component:

useTemplate('section');

If you want to consider multiple sections, call it successively:

useTemplate('section');
useTemplate('subsection');

Where 'subsection' will override 'section', if present.

See Also

Personal tools