Attention! We strongly recommend first to learn more about Sites module REST documentation to understand how the module functions (with REST available in Bitrix24 Self-hosted editions). View this documentation as useful source when working with Bitrix24 Self-hosted editions and find out more details about API and only REST is not enough.

Presently, system does not support hooks extensions, creataed by third-party developers. This information is for reference only.

Sites and pages have several settings described in chapters dedicated to additional fields of sites and pages. However, how does the system processes the data? For example, does it prints a corresponding analytics counter code, having only counter ID on input?

It is implemented via the hooks system. These are classes in the namespace Bitrix\Landing\Hook\Page. Single hook = single class = single file.

Each class consists minimum of three required methods:

  1. getMap(). Returns hook map outlining display sequence for settings fields.
  2. enabled(). This specific method defines hook triggering for an entity. For example, the above mentioned counter may be specified in settings, but "use counter" field (the same hook field) is not checkmarked.
    When the same hook is enabled for both a site and its page (enabled returns true), the page hook has the priority and it will be triggered first.
  3. exec(). Main executing method. It is triggered, when enabled returns true.

The data used for hook is stored in the linear table with hook's each field binded to the page/site.

Hook execution event

Set of hooks cannot be expanded yet, but hooks can be redefined.


$eventManager = \Bitrix\Main\EventManager::getInstance();
$eventManager->addEventHandler('landing', 'onHookExec',
   function(\Bitrix\Main\Event $event)
      $result = new \Bitrix\Main\Entity\EventResult;

         'METAOG' => function(/** @var \Bitrix\Landing\Hook\Page $hook */ $hook)
               '<meta property="og:image" content="/my/og/picture.png" />'

             // get array of all hook fields
             $fields = $hook->getFields();

             // get current value for specific field

            //must return true, when NOT required to execute system
            return true;

      return $result;

Example shows how to redefine the "Social network page" hook, or simply, og tags. Your event must return the array via modifyFields, where keys are hook codes which you want to redefine (a single code to be redefined in this case). Values are anonymous functions which will be called when executing a corresponding hook. Hook codes are listed below.

Attention!. Some system hooks can be disabled (for example, via interface option "Use"). However, after registering your handler, the system always registers it, because the system assigns handler execution to you.

Anonymous function receives a $hook instance of class \Bitrix\Landing\Hook\Page that can be used to handle all hook fields and their current data.

So, what hook codes do exist to be redefined?

Code Name
B24BUTTON Site widget
BACKGROUND Page background
GACOUNTER Google Analytics
GMAP Google Map
GTM Google Tag Manager
METAMAIN Page meta tags
METAOG Page display in social networks
METAROBOTS Search engine indexing
PIXELFB Facebook pixel location
PIXELVK Vkontakte pixel indexing
UP "Up" button
VIEW View type
YACOUNTER Yandex.Metrics

You can find how system hooks operate in the hook's namespace Bitrix\Landing\Hook\Page.

© «Bitrix24», 2001-2024