Documentation

Block editing

  • Update block from an app
  • Presently, developers have an option to integrate into edit options for any block. In case of such registration, a button to activate your app will appear near the buttons of "Edit" and "Design" blocks.

    The code to embed the app depends on the code of the block and generally looks as follows: LANDING_BLOCK_<CODE>. The block code must be inserted instead of <CODE> (see examples below). However, when inserting is performed into the block that is already registered by you, specify its ID.

    For example:

    1. Register a block. The method will return block ID. Let it be equal to 1132, for example.
    2. When registering embedding location, specify a code: LANDING_BLOCK_repo_1132 (or LANDING_BLOCK_REPO_1132, case insensitive)

    Parameters

    The following parameters are available for this embedding location:

    Parameter Description Available from version
    ID – block ID блока.
    CODE – block symbolic code.
    LID – landing page ID.

    Parameters can be retrieved from PLACEMENT_OPTIONS:

    $placement = isset($_REQUEST['PLACEMENT_OPTIONS'])
             ? json_decode($_REQUEST['PLACEMENT_OPTIONS'], true)
             : [];

    Example

    BX24.callMethod(
       'landing.repo.bind',
       {
          fields: {
             PLACEMENT: 'LANDING_BLOCK_04.1.one_col_fix_with_title',
             PLACEMENT_HANDLER: 'https://cpe/rt/placement.php',
             TITLE: 'My block'
          }
       },
       function(result)
       {
          if(result.error())
             console.error(result.error());
          else
             console.info(result.data());
       }
    );

    If you went to embed a universal application for each block, specify the code co *:

    pre class="syntax">BX24.callMethod( 'landing.repo.bind', { fields: { PLACEMENT: 'LANDING_BLOCK_04.1.one_col_fix_with_title', PLACEMENT_HANDLER: 'https://cpe/rt/placement.php', TITLE: 'My block' } }, function(result) { if(result.error()) console.error(result.error()); else console.info(result.data()); } );

    If you want to embed a universal app for each block, the со * code must be specified:

    BX24.callMethod(
       'landing.repo.bind',
       {
          fields: {
             PLACEMENT: 'LANDING_BLOCK_*',
             PLACEMENT_HANDLER: 'https://cpe/rt/placement.php',
             TITLE: 'My block'
          }
       },
       function(result)
       {
          if(result.error())
             console.error(result.error());
          else
             console.info(result.data());
       }
    )

    Updating block from the app

    The opened app has the command to update a specific block. After you worked the block used to call the app, you may need to update it. It is done via the refreshBlock command.

    Example

    BX24.placement.call(
       'refreshBlock',
       {
          id: 123//block with ID 123
       },
       function()
       {
          console.log('Block successfully updated');
          //close slider
       }
    );


    © «Bitrix24», 2001-2024
    Up