Template
The template engine used in Thelia is Smarty. There is 4 types of templates :
- frontOffice : for templates rendered from a controller that extend
BaseFrontController
- backOffice : for templates rendered from a controller that extend
BaseAdminController
- pdf : for pdf documents like invoices
- mail : for mail sent by Thelia
For each of this types you can choose an active template. Either by the configuration page in back office or by these environment variables:
ACTIVE_FRONT_TEMPLATE
ACTIVE_ADMIN_TEMPLATE
ACTIVE_MAIL_TEMPLATE
ACTIVE_PDF_TEMPLATE
It's strongly recommended to never modify the defaults templates but copy and rename it with the name of your project.
Like this you can always update Thelia and the defaults templates without loosing your changes
Templates structure
Thelia Smarty templates are located in the templates sub-directory.
\templates
\frontOffice
\default
\myTemplate
\backOffice
\default
...
\pdf
\default
...
\mail
\default
...
This is the structure of all Thelia templates, it can be located either at the root of your project or in each module folder. If same file are in multiple templates location, Thelia apply this priority to know which has to be rendered (the first file found is the file rendered)
- In the
active
template in root templates directory - In the
active
template in each module subdirectory located in root templates directory - In the
active
template in each module templates directory - In the "default" template in root templates directory
- In the "default" template in each module subdirectory located in root templates directory
- In the "default" template in each module templates directory
For example if you have this structure :
\local
\modules
\MyProject
\templates
\frontOffice
\default
template.html
\templates
\frontOffice
\default
template.html
\myTemplate
template.html
\modules
\myproject
template.html
It will check all these directories in this order :
\templates\frontOffice\myTemplate\
\templates\frontOffice\myTemplate\modules\myproject
* this for each activated modules\local\modules\MyProject\templates\frontOffice\myTemplate
* this for each activated modules\templates\frontOffice\default\
\templates\frontOffice\default\modules\myproject
* this for each activated modules\local\modules\MyProject\templates\frontOffice\default
* this for each activated modules
Features
Loops
Loops allow to get data from your shop back-end and display them in your front view. More documentation can be found here.
Smarty plugins
Smarty plugins are used to execute functions from templates. More documentation can be found here.