Documentation

copyBlock

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 copyBlock(
   $id,
   $afterId
);

Copies block from a page to the current page. Returns new block ID (added to the current page).

Parameters

ParameterDescriptionVersion
idBlock ID at the new page (it can be the current page as well). Copies this block ID to the current page. Copied block also must have draft version when working in the draft handling mode as well.
afterIdCurrent page block ID after which the copied block must be inserted.

Example

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

   $landing = \Bitrix\Landing\Landing::createInstance(
      1
   );
   if ($landing->exist())
   {
      var_dump($landing->copyBlock(46459, 6651));
   }
   
   foreach ($landing->getError()->getErrors() as $error)
   {
      echo $error->getCode() . ': ';
      echo $error->getMessage();
      echo "\n";
   }
}


© «Bitrix24», 2001-2024
Up