Bitrix list of infoblock elements in the management panel, add a team to the action menu



  • Versions 1C-Bitrix: site management 21.300.0

    There's a menu of action on the list of elements of the infoblock on the management panel. It has a list of teams that can be performed on one element.

    In the image below (through the public course of the Content Management) the column with the menu of action is given by figure 4.

    Список элементов инфоблока

    Tell me, as a regular means (e.g. through API), add your own team to the menu?



  • The file. init.php (Recommends) /local/php_interface/init.phpAdd the code:

    <?php
    AddEventHandler('main', 'OnAdminListDisplay', function (&$list) {
        $request = Application::getInstance()->getContext()->getRequest();
        $uri = new Uri($request->getRequestUri());
    
    parse_str($uri-&gt;getQuery(), $params);
    $currentIblockId = $params['IBLOCK_ID'] ?: null;
    
    // опционально: ограничение, для элементов каких инфоблоков добавляем действие
    /*if ($currentIblockId != &lt;id_инфоблока&gt;) {
        return;
    }*/
    
    /** @var \CAdminUiListRow[] $rows */
    $rows = $list-&gt;aRows;
    foreach ($rows as $row) {
        $row-&gt;aActions[] = [
            'TEXT' =&gt; 'Ракета',
            'TITLE' =&gt; 'Отправить ракету',
            'ACTION' =&gt; /** @lang JavaScript */ &lt;&lt;&lt;__js
                if (confirm('Вы действительно хотите отправить ракету?')) {
                    alert('Ракета отправлена!');
                }
            __js,
        ];
    }
    

    });

    As a result, the action menu will be added to the Rocket with a simple JavaScript processor.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2