Documentation

Object handling

Attention! We strongly recommend first to learn more about REST documentation for Sites module 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.

Landing page object has all characteristics of the landing page and contains all blocks for display (each block also is an object detailed in this course as well). Basic code for handling this object is provided below.

if (\Bitrix\Main\Loader::includeModule('landing'))
{
   \Bitrix\Landing\Landing::setEditMode(true);
   
   $params = [];
   $landing = \Bitrix\Landing\Landing::createInstance(
      1,
      $params
   );
   if ($landing->exist())
   {
      //landing handling
   }


   foreach ($landing->getError()->getErrors() as $error)
   {
      echo $error->getCode() . ': ';
      echo $error->getMessage();
      echo "\n";
   }
}

Array $params is an optional array of parameters containing the following keys:

  • force_deleted (true / false): fill the page with both existing and deleted blocks (deleted blocks are not shown by default)
  • blocks_limit (int): number of blocks, initiated on a page (by default, initiates all blocks associated with the page); value 1 is most convenient, when page object is created for specific actions not associated with blocks (for example, page copying)

Please note, initially draft version handling is configured via the method setEditMode. It's important, because each page can be filled with draft or published blocks.

Object handling ideology governs handling draft blocks first and then page is published via the method publication.

Following methods, described in this subsection are regulated by operation procedure described above (operation, instance creation, existence check, error display).

Attention! Error display is located separately, because the landing page processing error can occur not only on the first level, but inside the internal methods (for example, when publishing). First, its necessary to perform the required actions and then analyze existing errors.



© «Bitrix24», 2001-2024
Up