Advertisement
AlexeyGfi

Bitrix component custom title in edit mode

Jan 13th, 2021 (edited)
762
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.87 KB | None | 0 0
  1. <?php
  2. // telegram post: https://t.me/bitrixoid_iz_kolhoza/345
  3.  
  4.  
  5. // Class example
  6.  
  7. namespace AlexeyGfi;
  8.  
  9.  
  10. use CBitrixComponent;
  11. use CComponentPanel;
  12.  
  13. class ComponentParametersHinter
  14. {
  15.  
  16.     public static function placeSmartHint($componentLabels = null): void
  17.     {
  18.         global $APPLICATION;
  19.  
  20.         $bDrawIcons = $APPLICATION->GetShowIncludeAreas();
  21.         if (!$bDrawIcons) {
  22.             return;
  23.         }
  24.  
  25.         $componentName = $componentLabels['componentName'] ?? null;
  26.         $menuTitle = $componentLabels['menuTitle'] ?? null;
  27.  
  28.         if (!$menuTitle || !$componentName) {
  29.             return;
  30.         }
  31.  
  32.         $componentTemplate = $componentLabels['componentTemplate'] ?? '.default';
  33.         $parentComponent = $componentLabels['parentComponent'] ?? null;
  34.  
  35.         echo $APPLICATION->IncludeStringBefore();
  36.  
  37.         $component = new CBitrixComponent();
  38.         if ($component->InitComponent($componentName)) {
  39.             $panel = new CComponentPanel(
  40.                 $component,
  41.                 $componentName,
  42.                 $componentTemplate,
  43.                 $parentComponent,
  44.                 true
  45.             );
  46.  
  47.             $arIcons = $panel->GetIcons();
  48.  
  49.             $arIcons['parameters']['COMPONENT_DESCRIPTION']['NAME'] = $menuTitle;
  50.             $arIcons['parameters']['TOOLTIP']['TITLE'] = $menuTitle;
  51.  
  52.             echo $s = $APPLICATION->IncludeStringAfter(
  53.                 $arIcons['icons'],
  54.                 $arIcons['parameters']
  55.             );
  56.         }
  57.     }
  58.  
  59. }
  60.  
  61.  
  62. // Usage example
  63. // ...don't forget set ['HIDE_ICONS' => 'Y']
  64.  
  65. use AlexeyGfi\ComponentParametersHinter;
  66.  
  67. ComponentParametersHinter::placeSmartHint([
  68.     'componentName' => 'bitrix:catalog.section.list',
  69.     'componentTemplate' => 'fotogallery.katalog.sections',
  70.     'parentComponent' => $this,
  71.     'menuTitle' => 'Товары на фото'
  72. ]);
  73.  
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement