Documentation

Features

Templates, widgets and themes

There is more to it than just comfort!

A template is just a simple PHP file with regular HTML code and PHP content. Just create a template for an addon's action and customize it with widgets from another addon. This way you can have web page completed in less than a minute. Each action of an addon can have its own template or reuse the template of another action by writing:

$this->app->set_template('another_temaplate');

How do we make use of a widget in a template?

Let's assume you have an addon named 'home' with an action called 'welcome'. Then include something like the code below in your template:

...some html content <!-- widget addon="home" action="welcome" params="name=Anna|age=24" --> ...

When this template should be displayed, the HTML comment will be replaced by the result of the method "welcome" from the addon "home".

To use methods defined in the same addon class, you could use:

<!-- widget addon="__THIS__" -->

To make things easier, if you leave the action parameter out, the main method of the addon will be called.

If you are more inclined to write everything in PHP instead of inserting snippets of code in an HTML file, we provide an alternate syntax:

<?php $this->lib->addons->home->welcome(array('name' => 'Anna', 'age' => 24)); ?>

So we have two ways of calling widgets in a template file.

A note is in order here: in the template file '$this' refers to the addon object, that called this template. In other words, '$this' is the owner of the template.

Also, take a look at the aliasing feature, which allows you to change or define templates for each action of an addon.