Содержание
Introduction to InstantCMS templates
InstantCMS templates are located in subcategories of the /templates/
directory. The template directory may contain CSS tables, JavaScript files, files of output templates, helper function file, template options form and various images.
For instance, the template called «test» is located in the /templates/test/
directory.
There is the «default» template in InstantCMS by default. For a better understanding of how to create a custom template, carefully examine the files it contains.
InstantCMS does not use any template engine like Smarty or Twig. All code is written in PHP. The main purpose of InstantCMS templates is to separate presentation from logic.
What kind of template files can be?
Under template files we assume certain files with the .tpl.php
double extension. In other words, the files are ordinary PHP files, while the second .tpl extension indicates the template file. In the full title of the file, anything that comes before .tpl.php
is the template title. For example, a file is called index.tpl.php
- the engine will operate with the index
name only.
An InstantCMS template consists of a common layout (there can be more than one) and output files-templates.
A common layout is the main template of all site pages and contains the <html>, <head> and <body> tags. The templates of components and widgets are output inside it. By default, the engine uses two layouts: main.tpl.php for the site and admin.tpl.php for the Control panel.
Output template files are intended to display the work results of controllers, widgets or other subsidiary actions, for example, error messages, output of form fields.
A list of standard template files and directories
The path to the files from the tables below is specified relative to the template’s root directory, i.e., if a template is located in the /templates/test/
directory, the paths below are specified relative to /templates/test/
.
Required template files
File path | Assignment |
---|---|
main.tpl.php | Main template layout |
admin.tpl.php | Control panel layout * |
scheme.html | Template position layout |
* The file is required if other than the default template is chosen for the Control panel. On the contrary, the template may not contain this file.
Other files and directories
Path to a file or directory | Assignment |
---|---|
options.form.php | template options form's file |
assets/errors/ | error templates, 404 page template and messages notifying that the site is closed |
assets/fields/ | templates of form fields |
assets/ui/ | templates of “breadcrumbs”, content filter panels, forms, menus and Control panel entry lists |
content/ | templates of entry lists and content type entry pages |
controllers/CONTROLLER/ | controller frontend templates |
controllers/CONTROLLER/styles.css | controller CSS file |
controllers/CONTROLLER/backend/ | controller backend templates |
controllers/CONTROLLER/backend/styles.css | controller backend's CSS file |
controllers/CONTROLLER/widgets/WIDGET/ | controller widget templates |
css/ | template CSS files linked in the layout |
images/ | images used in a template |
js/ | JavaScript scripts used in a template |
js/fields/FIELD_TITLE.js | JavaScript script automatically linked to a template field |
profiles/options.form.php | an option form to customize user profiles |
profiles/styler.php | a set of dynamically created CSS styles to customize user profiles |
widgets/ | a directory of widget templates not linked to controllers |
widgets/wrapper*.tpl.php | files-wrappers in which the widget work results are displayed |
How the engine works with template files
There is an inheritance mechanism of template files in InstantCMS. This means that when linking a relevant template file, css and javascript files, the engine searches it in the current template first and then in other templates, if the inheritance chain is specified. The default template is always the root of the chain. Read more about the inheritance mechanism here.