Documentation

updateNodes

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 updateNodes(
   $data
)

Mass update of node content.

Parameters

ParameterDescriptionVersion
dataArray of selectors and node values. Keys are: card positions to be updated. Values can have various formats depending on type. See the example for more details.

Examples

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->updateNodes([
               '.landing-block-node-title' => [
                  2 => 'Title 2',
                  4 => 'Title 4'
               ],
               '.landing-block-node-text' => [
                  2 => 'Text 2',
                  4 => 'Text 4'
               ],
                     '.landing-block-node-img' => [
                        1 => [
                           'src' => '/some/path/picture.png', 
                     'alt' => 'My image'
                  ]
               ],
                     '.landing-block-node-link' => [
                        1 => [
                           'text' => 'Моя ссылка', 
                     'href' => 'https://bitrix24.com', 
                     'target' => '_blank'
                  ]
               ],
                     '.landing-block-node-icon' => [
                        1 => [
                           'fa-facebook', 'fa-instagram'
                  ]
               ],
                     '.landing-block-node-embed' => [
                        1 => [
                           'src' => '//www.youtube.com/embed/q4dsfsfs8g9Dn3ww?autoplay=1&controls=0&loop=1&mute=1&rel=0', 
                     'source' => 'https://www.youtube.com/watch?v=sdfq4d8g9Dn3ww'
                  ]
               ],
            ]);
            $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