Alternative implementation of templates in 1C-Bitrix
To begin, let me remind you how the templates are implemented in the standard form for 1C-Bitrix. All templates are stored in the / bitrix / templates / folder. The template folder contains the required files header.php and footer.php. In essence, these two files together form a page template, i.e. first header.php is connected, then page content, then footer.php. The scheme is stupid to madness. First of all, the pattern is divided into two parts and it is possible to edit it as a whole only through the administration system. And this is a clinic. The second inconvenience of such a scheme is that we, in fact, cannot use the variable pages in the header.php part, because at the time of the first part of the template call, the system does not “know” about these variables. Of course, you can use the proposed option of data buffering, but again such variables can only be used for output. Typical situation. A certain parameter is set on the page that determines whether to show the page title or not. It’s not possible to do this using standard Bitrix tools, since the title is shown before the page content. The way out is to use your own template system. I developed it a year and a half ago and successfully use it in all my projects. So, the system looks like this. We buffer all the content of the page, connect the template and insert the content into it as a variable. The practical implementation is as follows:
As a result, we have a holistic site template in the template.php file. We solve two main problems voiced earlier. The only negative is that editing the template through the admin panel is no longer possible. Although it can also be considered a plus.