Views: 4420 (Data available since 06.02.2017)
Template editing is one of the means to obtain the result of the component work that is appropriate for each specific website. Editing the system template is not recommended because after the very first update, the system template will recover its initial state. Only user template can be edited and used.
When starting to customize a template, please remember:
All logic must be located in the component, and the template must contain only the display representation of the data obtained!
As a rule, component template customization is aimed at:
- Adjusting the component data display form according to the website design;
- Arranging for component data display in a way unavailable as a standard option.
User templates of a component are the templates that are changed to meet the requirements of a specific project. They must be located in the portal template folders (i.e. in
/bitrix/templates/site_template/). When copying component template using system means they will be located at:
A template can be copied as follows:
- Within the file system – by coping the folder
/bitrix/components/bitrix/_required_component_/templates/ to the folder
- Using system interface means using the command Copy component template (with Edit Mode activated):
When copying the template, its application to a component can be set and a template editing form can be opened at once:
It is possible not to apply the copied template to a component at once, but rather to do it later on by selecting the template in the component settings.
Important! If during component template editing you add new identifiers of language messages, please remember that the identifiers must be unique throughout the entire product.
Template editing admits adding action logic, but such a modification should be made in the files result_modifier.php and component_epilog.php (which must be located in the template folder) for a more complex change of work result.
The chapter provides for some examples of template customization.