Each module in Automne can generally use a <block> tag in content rows, in order to use simple or complex dynamic content.
Here we deal with classic modules, made manually with PHP.
Data blocks
<block module="cms_forms" id="blockID" type="formular"> ... </block>
Modules created in PHP take into account the <block> tag in the content rows from Automne v. 4
Prior to this it was necessary to indicate the inclusion of <block> tag classes in the module concerned.
For a classic module the <block> tag will be replaced by default with a "module model". This is a file located in /automne/templates/.
The block tag is replaced by the file /automne/templates/mod_[module]_[type].php.
Where [module] is the codename of the module and [type] is the type indicated in the block type.
Be careful to use a unique type, without special characters.
Example :
The following tag:
<block module="cms_forms" id="blockID" type="test"> ... </block>
will be replaced by the content of the file:
/automne/templates/mod_cms_forms_formular.php
It is very useful to use the module models.
They insert a PHP code from an external file to that of the row, and authorize the modification of headers via PHP.
Recovery of the attributes values
In your module model, it is possible to recover the attributes of the block tag. The value of attributes is automatically stored in the table $mod_[module].
Where [module] is the codename of the module.
Example :
For the tag:
<block module="formations" id="formationsAccueil" type="homepage" myAttribute="maformation"> ... </block>
The file /automne/templates/mod_formations_homepage.php will contain, for example:
<?php
// Module template
echo $mod_cms_forms['myAttribute']; // maformation
?>
Add a contribution