Documentation

favoriteBlock

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.

public function favoriteBlock(
    $id,
    $meta
);

Method save the block, available at the "My blocks" page. Returns ID for new saved block.

Note: Method can be useful when deleting a saved block.

Parameters

ParameterDescriptionVersion
$idBlock ID.
$metaArray with information for saved block. Contains the following fields:
  • name – block name;
  • section – array with categories, to save the block;
  • preview – block image.

Example

if (\Bitrix\Main\Loader::includeModule('landing'))
{
   \Bitrix\Landing\Landing::setEditMode(true);

   $landing = \Bitrix\Landing\Landing::createInstance(20450);
   if ($landing->exist())
   {
      $landing->favoriteBlock(65656, [
         'name' => 'Мой блок',
         'section' => ['text_image', 'text'],
         'preview' => 'https://mycdn.com/pic/1.jpg'
      ]);
   }

   foreach ($landing->getError()->getErrors() as $error)
   {
      echo $error->getMessage() . '<br/>';
   }
}

© «Bitrix24», 2001-2024
Up