The synonyms of the term "site template" are "site design",
"site skin". Several templates may be used to display a site.
In the strict sense, a site template comprises:
- database account - created in the administrative menu Site
templates;
- set of files in the directory /bitrix/templates/template ID/,
where the template ID is the ID field in the site template
editing form (the Site templates administrative menu). The structure of this
directory is described below:
- header.php - prologue
of this template;
- footer.php - epilogue
of this template;
- styles.css - CSS used by this template;
- .menu type.menu_template.php - template
used to display
a menu of the corresponding type;
- chain_template.php - default template used to display
the navigation chain;
- /module ID/ - directory with components of
a module;
- /lang/ - language files
used by this template and components;
- /images/ - directory with images used by this template;
- /page_templates/ - directory with page
templates and their descriptions stored in file .content.php;
- other helper files used by this template.
A template can be applied to a site in the administrative menu Sites,
in the site settings (click the Modify link), the Design section:

The site template is selected by calling CSite::GetCurTemplate;
its algorithm can be described as follows:
- All site templates are chosen in the following order:
- those containing the PHP condition (the highest priority);
- sort weight (the less is the value the higher is the priority);
Thus, templates containing either the PHP condition or the less sort
weight value, will have the highest priority.
- Then, the loop iterates on all the chosen templates. If the template
contains the PHP condition, it is evaluated and if the result is
"true", the path /bitrix/templates/site template ID/
is checked for existence. It this path exists, the loop breaks
and the function CSite::GetCurTemplate returns this site template ID.
- In case none of the templates could be matched, the default template .default.php
is returned.
When specifying the PHP condition, it should be considered that the check is
implemented by the function which has its own scope of variables. That's
why the global variables should be specified by using the array $GLOBALS, the request variables - through the array $_REQUEST (or $_GET, $_POST) etc.
The current site template is determined at the end of the prologue service section (prolog_before.php). Hence, the following can be
used:
- $APPLICATION object of the CMain
class;
- $USER object of the CUser
class;
- all the system constants
of the type A;
- all the standard PHP arrays: $GLOBALS, $_REQUEST, $_SERVER, $_SESSION, $_ENV, $_COOKIE
etc.
When specifying the PHP condition for choosing the site template, it should be
considered that the use of section
properties is allowed, while page
properties are not allowed. This is because the section properties are stored in a
separate file .section.php, and the page properties are specified usually
in a page body, after the including
the prologue service section.
Note!
In the public section,
the current site template ID is stored in the constant SITE_TEMPLATE_ID.
Examples of specifying the conditions for inclusion of a site template
If a request (GET or POST) contains the parameter print equal to "Y":
$_REQUEST["print"]=="Y"
If the section property phone is "Y":
$APPLICATION->GetDirProperty("phone")=="Y"
If the current section is "/en/catalog/phone/":
$APPLICATION->GetCurDir()=="/en/catalog/phone/"
Is the current user is an administrator:
$USER->IsAdmin()