Creating a Qtag
Each Qtag in Quanta, indeed, corresponds to a Class in the \Quanta\Qtag namespace, extending the basic Qtag class.
In order to create a Qtag, you should first of all have created created a custom module.
The class file should be placed in your custom module's classes\Qtags folder, as in the example below.
i.e. if your module is called "my_module", and you want to create a Qtag named [MY_FIRST_TAG], you will simply create a MyFirstQtag.class.qtag.php file in your my_module\classes\Qtags folder.
That file will be automatically included at runtime, and will contain the class corresponding to the Qtag.
The class - at its basic - will be structured as follows:
class MyFirstQtag extends Qtag {
/**
* Render the Qtag.
*
* @return string
* The rendered Qtag.
*/
public function render() {
return t('Hello world!');
}
}
Here you go! From now on, by writing [MY_FIRST_QTAG] anywhere in your tpl.html, index.html or content body, your qtag will be automatically converted into:
Hello world!
The Object Oriented approach makes it easy and functional to create Qtags and extend them when you need.