Aliro is Open Source

Documents

Performance

Memory limit is 16M

Current usage = 3.16M

Database queries = 8

Time so far 0.131 seconds

Home arrow Template Architecture

Template Architecture

Aliro User Templates

Basics

Further development has been done since this was written, and Aliro templates are now best written by inheriting from the aliroUserTemplateBase abstract class. This makes it even easier to create an Aliro template (user side). The documentation will be updated soon.

An Aliro User Template is implemented as a PHP class that provides the methods defined as the “ifAliroTemplate” interface. It can include other classes if desired. Currently, the required interface provide the following methods:

  • positions();
  • defaultModulePosition ();
  • render();
  • component_render();
There can also be optional methods: moduleStyleX ($moduleclass_sfx, $title, $content);

Briefly, the methods provide the following services. The “positions” method returns an array of objects of the class aliroUserScreenArea. These represent the possible areas of the browser window that are supported by this template. Calling the “render” method causes the complete HTML for the current display to be created, with the help of other cooperating objects. A much reduced version of this is the “component_render” method which outputs a minimal HTML framework around the output of the current component. The moduleStyle methods are given the material created by individual modules so that the template has full control over styling.

Screen Areas

In the Mambo/Joomla environment, these have typically been known by place indicators, such as “left”, “right”, “top” and so on, although some functional names have been used, such as “user1” or “banner”. Aliro is leaning towards the use of completely functional names, although this is open for discussion. It seems to make more sense to place a menu in an area called “navigation” than an area called “left”, especially when template designers have sometimes chosen to place the “left” screen area on the right!

The explicit introduction of screen areas as objects allows them to have more functionality and to provide a way for information to pass between the template and other display code. To create a screen area, a new object of class aliroUserScreenArea is created with a call something like:

new mosUserScreenArea ($position, $minvalue, $maxvalue, $style);

The first parameter ($position) is a string naming the screen area. The second parameter is the minimum width in pixels of the screen area, and the third parameter is the maximum value. This information will be passed to modules to assist them in building their output. The final $style parameter must be linked to the template's own moduleStyle methods. Suppose the $style parameter has the value 1. Every time a module creates output within this screen area, a call will be made to the template's moduleStyle1 method. The template therefore has quite detailed control over the styling of module output. For creation of the final complete screen, the material for a whole screen area is provided back to the template in a single call to the screen area object. Although numbers have been used in this explanation, a template is probably easier to read if strings are used to identify the different styles.

When a template's positions() method is called, it must return an array of strings, where the strings are the names of the screen areas supported by the template. Also, the template must provide a static method, defaultModulePosition() which returns a string indicating which screen area should be used by default.

Rendering methods

These are the ways in which the template is called to provide a page of output. Typically the output will commence with a Doctype declaration and end with an HTML terminator (