Documentation

landing.block.updatenodes

landing.block.updatenodes(lid, block,data)

This method updates the block content. Return true or an error. Also, this method is used to update parameters of dynamic blocks, such as list of products, product items and some others.

Parameters

Method Description Available from version
lid Landing page ID
block Block ID
data Array of selectors and new values.
For example: data: {'.landing-block-node-text@1': 'new text!'}. The principle is the same - selector and its new value. If you are sure, that selector is the only one, then in this case, you can discard the counter @1.

Also, 'data' depends on types of updated nodes. See example below for details and go to the separate page for descriptions of types.

Example

BX24.callMethod(
    'landing.block.updatenodes',
    {
        lid: 311,
        block: 6058,
        data: {
           '.landing-block-node-text': 'Текст, с html',
           '.landing-block-node-img': {src: '/some/path/picture.png', alt: 'Моя картинка'},
           '.landing-block-node-link': {text: 'Моя ссылка', href: 'https://bitrix24.com', target: '_blank'},
           '.landing-block-node-icon': ['fa-facebook', 'fa-instagram'],
           '.landing-block-node-embed': {src: '//www.youtube.com/embed/q4d8g9Dn3ww?autoplay=1&controls=0&loop=1&mute=1&rel=0', source: 'https://www.youtube.com/watch?v=q4d8g9Dn3ww'},
       },
    function(result)
    {
        if(result.error())
        {
            console.error(result.error());
        }
        else
        {
            console.info(result.data());
        }
    }
);

Editing parameters of dynamic blocks

There are several dynamic blocks which parameters can be changed via REST. For example, number of product shown on a page. It can be done as detailed below.

  1. The method landing.block.getmanifest allows to get the block's available parameters. The method returns a manifest array with the attrs key and the parameters of the required dynamic block component. In this case, we are interested in bitrix:catalog.section.
    attrs:
    bitrix:catalog.section: Array(24)
    0: {name: "Section ID", style: false, original_type: "component", component_type: "STRING", attribute: "SECTION_ID", …}
    1: {name: "Unavailable products", style: false, original_type: "component", component_type: "LIST", attribute: "HIDE_NOT_AVAILABLE", …}
    2: {name: "Unavailable estimates", style: false, original_type: "component", component_type: "LIST", attribute: "HIDE_NOT_AVAILABLE_OFFERS", …}
    3: {name: "element sorting field", style: false, original_type: "component", component_type: "LIST", attribute: "ELEMENT_SORT_FIELD", …}
    4: {name: "Element sorting order", style: false, original_type: "component", component_type: "LIST", attribute: "ELEMENT_SORT_ORDER", …}
    5: {name: "Target currency used to convert prices", style: false, original_type: "component", component_type: "LIST", attribute: "CURRENCY_ID", …}
    6: {name: "Price type", style: false, original_type: "component", component_type: "LIST", attribute: "PRICE_CODE", …}
    ...
  2. Used the method landing.block.updatenodes to modify the required parameters. In general, this method is used to change dynamic parameters (attributes)
    BX24.callMethod(
       'landing.block.updatenodes',
       {
          lid: 5597,
          block: 44131,
          data: {
             'bitrix:catalog.section': {
                attrs: {
                   'MESS_BTN_BUY': 'Add to my cart'
                }
             }
          },
          function(result)
          {
             if (result.error())
             {
                console.error(result.error());
             }
             else
             {
                console.info(result.data());
             }
          }
       }
    );


© «Bitrix24», 2001-2024