Views: 477 (Data available since 06.02.2017)
Last Modified: 19.09.2014

Before starting work in Bitrix Framework you have to understand the main rules that will help you to avoid many mistakes:

  • Collect the statistics on the use of the functionality that you need to adjust;
  • If you want to make any changes to the website operation, perform the following:
    • First formalize your needs on paper, do not start correcting the code immediately.
    • After that’s done, take another look at all the cases when the block you want to modify is used on the website. Make sure everything is logical. Very often some seemingly small changes negatively affect some related functionality that was omitted or forgotten.
    • After you have formalized your need to make changes, check which entities are affected by these requirements.
    • Only after that think as to which means should be used to achieve your goals.
  • Ways to make changes and preferred order of their application:
    • First try to this by editing the template of the website itself and CSS files;
    • If that is impossible, try to do it by way of website page editing;

      Note: This means must be approached with care. If you add code without due care, the components may end up framed in code that should have been placed in the component template and not on a page.

    • If the task cannot be solved using the first options, go to the editing of component templates and CSS files of the component or change data output using the files result_modifier.php and component_epilog.php.
    • Use event handlers, that permit solving a very wide range of tasks.
    • Component customization or development of an own component or a module is the last of possible options in order to achieve a non-standard functionality.
  • Writing HTML code into PHP code in order to change data representation is not recommended. Logic and representation are separated in components 2.0. Logic is the component per se, and representation is the template of the component display. A template is significantly simpler than a component in general. There is no need to change the logic of a component in order to change the particulars of its data output. There can be several representations for the same logic, including representations that depend on the template of the current website. Representation (output template) can be written in any template language that may be connected from PHP. For example, templates can be written in PHP, Smarty, XSL, etc.
  • Own components and templates should be located in their own namespace. When customizing standard components and templates or developing your own, place them in an own namespace. All the changes made in the bitrix space will be eliminated upon system update.
  • Do not access the database directly when working with components. The concept of working with the product involves working with data through the API function. The structure of data may change in each version, but the functions maintain backward compatibility. We strongly discourage using direct database queries because it may breach the integrity of the data and result in the inoperability of the website. Due to the aforementioned, the structure of tables is not disclosed.
  • The kernel code should not be corrected due to the following reasons:
    • The changes made will be eliminated after a system update;
    • By changing the kernel, the license holder loses the right to refer to the technical support service;
    • When a website developer changes the kernel, it may result in the incorrect operation of the system because the kernel is a complex system that requires the operation of all of the modules to be taken into account.
    Product kernel - consists of files located in the directory /bitrix/modules/ and also the files of the system components: /bitrix/components/bitrix/.

Attention! he files that cannot be accessed directly (they must not be executed by direct access using an address in the browser) must contain the following verification code in the beginning:

<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>

These files include all the files that operate inside the product, e.g. website templates, component templates, files .parameters.php and .description.php.

Courses developed by «Bitrix», Inc.