Views: 884 (Data available since 06.02.2017)
Last Modified: 20.09.2017
A composite component ensures the interaction of simple components with the general subject. Simple components contain the code of immediate work with data. For example, it is inconvenient to set up the components of a social network one by one.
However, if you only seek to change the external appearance of some elements, it can be easily done without refusing other standard templates.
For example, you need to change the form of the news list, and the entire news section is built using a composite component. The list of news is built using the simple component List of news (news.list) which, similarly to the component templates for building a detailed news page, feedback, search, etc., forms part of the composite component template News (news). When copying the News template to the site template by using the option Copy component template of the context menu of the component, all of the files of the component template are copied to the website template. This means that when the News component template is updated through the Site Update you, by using a customized template, will lose the template update of all other templates included in the composite component (do not worry, standard templates and components are getting updated as usual). In order to customize only the component template List of news (news.list) and to make sure the composite component News connects it but uses the other standard (updated) templates of the templates included into the composite component, do the following:
- Create the folder news (or, depending on the composite component, a part of the template you need to customize) manually through file structure of the website in the website template folder (.default or current)
- Copy the template of the simple component so that its path resulted as follows:
- Edit the template obtained
The same approach can be used to edit the templates of simple components connected from the templates of composite components (i.e. when a template of a simple component does not form part of a composite component, and when a simple component is connected in the script of a composite component using the method CMain::IncludeComponent()).
For example, you have to change the form of creating/editing a group. In a social template Bitrix24 this form is built using the component Create new group in modal dialog box (socialnetwork.group_create.ex) to be connected from the composite component Social Network (socialnetwork_group).
If no modification of other parts of the composite component is needed, it will suffice to copy the component template socialnetwork.group_create.ex to the website template (
/bitrix/templates/site_template/components/bitrix/socialnetwork_group/.default/bitrix/socialnetwork.group_create.ex/.default/) and modify it there.
In this case, all remaining code will remain standard, i.e. it will be updated and supported by Bitrix, Inc.