本文整理汇总了PHP中yii\widgets\Menu::renderItem方法的典型用法代码示例。如果您正苦于以下问题:PHP Menu::renderItem方法的具体用法?PHP Menu::renderItem怎么用?PHP Menu::renderItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\widgets\Menu
的用法示例。
在下文中一共展示了Menu::renderItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderItem
/**
* @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: renderItem
/**
* 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: renderItem
/**
* 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);
}