Documentation

cloneCard

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.

public function cloneCard(
   $selector, 
   $position, 
   $content = ''
)

Clones card details. Returns true on success.

Parameters

ParameterDescriptionVersion
selectorCard selector.
positionCard position, after which cloned card is to be inserted (counting from zero). For example, when passing 1, inserts card after the second card (0, 1, ..), with second card as data source.
content Option to change cloned card content with the passed content.

Example

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

   $landing = \Bitrix\Landing\Landing::createInstance(
      5675
   );
   if ($landing->exist())
   {
      foreach ($landing->getBlocks() as $block)
      {
         if ($block->getId() == 46613)
         {
            $block->cloneCard('.landing-block-card', 0);
            $block->save();
            $landing->getError()->copyError(
               $block->getError()
            );
         }
      }
   }


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


© «Bitrix24», 2001-2024
Up