renderItem() защищенный Метод

Note that the container and the sub-menus are not rendered here.
protected renderItem ( array $item ) : string
$item array the menu item to be rendered. Please refer to [[items]] to see what data might be in the item.
Результат string the rendering result
Пример #1
0
 /**
  * @inheritdoc
  */
 protected function renderItem($item)
 {
     $renderedItem = parent::renderItem($item);
     if (isset($item['badge'])) {
         $badgeOptions = ArrayHelper::getValue($item, 'badgeOptions', []);
         Html::addCssClass($badgeOptions, 'label pull-right');
     } else {
         $badgeOptions = null;
     }
     return strtr($renderedItem, ['{icon}' => isset($item['icon']) ? new Icon($item['icon'], ArrayHelper::getValue($item, 'iconOptions', [])) : '', '{badge}' => (isset($item['badge']) ? Html::tag('small', $item['badge'], $badgeOptions) : '') . (isset($item['items']) && count($item['items']) > 0 ? new Icon('fa fa-angle-left pull-right') : '')]);
 }
Пример #2
0
 /**
  * Renders the content of a menu item.
  * Note that the container and the sub-menus are not rendered here.
  * @param array $item the menu item to be rendered. Please refer to [[items]] to see what data might be in the item.
  * @return string the rendering result
  */
 protected function renderItem($item)
 {
     if ($this->showIcon && isset($item['url'])) {
         if (!strpos($item['label'], '</i>')) {
             $item['label'] = strtr($this->iconTemplate, ['{icon}' => isset($item['icon']) ? $item['icon'] : $this->defaultIcon, '{label}' => $item['label']]);
         }
     }
     if (isset($item['items'])) {
         $item['label'] .= $this->showCountSubmenu ? strtr($this->countSubmenuTemplate, ['{count}' => count($item['items'])]) : '<i class="fa fa-angle-left pull-right"></i>';
     }
     return parent::renderItem($item);
 }
Пример #3
0
 /**
  * Renders the content of a menu item.
  * Note that the container and the sub-menus are not rendered here.
  * @param array $item the menu item to be rendered. Please refer to [[items]] to see what data might be in the item.
  * @return string the rendering result
  */
 protected function renderItem($item)
 {
     if (isset($item['url'])) {
         if ($this->useSprites) {
             $spriteUrl = $this->spriteUrl;
             $item['template'] = "<a href=\"{url}\" style=\"background: no-repeat 0 {$this->itemOffset}px url({$spriteUrl});\">{label}</a>";
             $this->itemOffset -= 16;
         } else {
             $components = parse_url($item['url']);
             $iconUrl = $this->iconizerBaseUrl . $components['host'];
             $item['template'] = "<a href=\"{url}\" style=\"background: no-repeat url({$iconUrl})\">{label}</a>";
         }
     }
     return parent::renderItem($item);
 }