本文整理汇总了PHP中yii\widgets\Menu::run方法的典型用法代码示例。如果您正苦于以下问题:PHP Menu::run方法的具体用法?PHP Menu::run怎么用?PHP Menu::run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\widgets\Menu
的用法示例。
在下文中一共展示了Menu::run方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Renders the menu.
*/
public function run()
{
// Get Module list
$modules = array_keys(Yii::$app->modules);
// Get sub menu for each module
foreach ($modules as $moduleName) {
// Get module
$moduleObj = Yii::$app->getModule($moduleName);
$iconClass = isset($moduleObj->iconClass) ? $moduleObj->iconClass : 'fa-dashboard';
// Get menu
if (property_exists($moduleObj, 'backendMenu')) {
$getModule = Yii::$app->request->get('module');
$item = ['label' => Icon::show($iconClass) . '<span class="nav-label">' . Yii::t($moduleName, ucfirst($moduleName)) . '</span>', 'url' => ['/' . $moduleName . '/default']];
if (Yii::$app->controller->module->id == $moduleName and empty($getModule) or $getModule == $moduleName) {
$item['active'] = TRUE;
}
$backendMenu = $moduleObj->backendMenu;
if (is_array($backendMenu)) {
foreach ($backendMenu as $itemMenu) {
if (isset($itemMenu['access']) and $this->checkAccess($itemMenu['access'])) {
$item['items'][] = ['label' => $itemMenu['label'], 'url' => $itemMenu['url']];
}
}
if (isset($item['items']) and !empty($item['items'])) {
$item['label'] .= '<span class="fa arrow"></span>';
}
}
// assign to $this->items
$this->items[] = $item;
}
}
parent::run();
}
示例2: run
/**
* Renders the menu.
*/
public function run()
{
$this->options = ['tag' => 'ul', 'class' => 'nav navbar-nav navbar-right'];
$this->encodeLabels = false;
$this->items[] = ['label' => \Yii::t('app', 'Home'), 'url' => [DummyModel::getHomeRoute()]];
/** @var ArticleCategory[] $categories */
$categories = ArticleCategory::find()->from(['t' => ArticleCategory::tableName()])->joinWith(['articles'], true, 'RIGHT JOIN')->andWhere(['t.published' => 1])->orderBy('t.position DESC, t.id')->groupBy('t.id')->all();
\Yii::$app->params['categoryModels'] = $categories;
foreach ($categories as $category) {
$this->items[] = ['label' => $category->label, 'url' => [ArticleCategory::getIndexRoute(), 'alias' => $category->alias]];
}
parent::run();
}
示例3: run
/**
* Renders the menu.
*/
public function run()
{
$controller = \Yii::$app->controller;
$moduleObj = $controller->module;
$paths = [];
$moduleId = isset($moduleObj->id) ? $moduleObj->id : false;
if ($moduleId && in_array($moduleId, ['fin', 'net', 'jar', 'oef'])) {
$paths[] = $moduleId;
}
$paths[] = $controller->id;
$this->objectId = isset($controller->objectId) ? $controller->objectId : false;
$this->pathPattern = '/^\\/' . implode('\\/', $paths) . '\\/.*$/';
parent::run();
}
示例4: run
public function run()
{
ob_start();
parent::run();
$body = ob_get_contents();
ob_end_clean();
// Adds the header
if ($this->header) {
$encodeHeader = ArrayHelper::getValue($this->options, 'encodeHeader', TRUE);
$header = strtr($this->headerTemplate, ['{header}' => $encodeHeader ? Html::encode($this->header) : $this->header]);
$body = $header . $body;
}
echo Html::tag('div', $body, ['class' => 'sidebar']);
}
示例5: run
public function run()
{
if ($this->cache) {
/** @var Cache $cache */
$this->cache = Instance::ensure($this->cache, Cache::className());
$cacheKey = [__CLASS__, $this->items];
if (($this->items = $this->cache->get($cacheKey)) === false) {
$this->items = ModuleEvent::trigger(self::EVENT_FETCH_ITEMS, new MenuItemsEvent(['items' => $this->items]), 'items');
$this->cache->set($cacheKey, $this->items, $this->cacheDuration, $this->cacheDependency);
}
} else {
$this->items = ModuleEvent::trigger(self::EVENT_FETCH_ITEMS, new MenuItemsEvent(['items' => $this->items]), 'items');
}
$this->items += $this->customItems;
parent::run();
// TODO: Change the autogenerated stub
}
示例6: run
/**
* Renders the widget.
*/
public function run()
{
parent::run();
$view = $this->getView();
$id = $this->options['id'];
if ($this->clientOptions !== false) {
$options = empty($this->clientOptions) ? '' : Json::encode($this->clientOptions);
$js = "jQuery('#{$id}').menu({$options});";
$view->registerJs($js);
}
if (!empty($this->clientEvents)) {
$js = [];
foreach ($this->clientEvents as $event => $handler) {
$js[] = "jQuery('#{$id}').on('menu{$event}', {$handler});";
}
$view->registerJs(implode("\n", $js));
}
}
示例7: run
/**
* Renders the widget.
*/
public function run()
{
echo Html::beginTag('div', ['class' => 'page-sidebar-wrapper']);
echo Html::beginTag('div', ['class' => 'page-sidebar navbar-collapse collapse']);
parent::run();
echo Html::endTag('div');
echo Html::endTag('div');
}
示例8: run
/**
* Renders the widget.
*/
public function run()
{
echo Html::beginTag('div', ['class' => 'page-sidebar-wrapper']);
echo Html::beginTag('div', ['class' => 'page-sidebar navbar-collapse collapse']);
echo Html::beginTag('ul', $this->options);
echo $this->toggleMenu ? $this->toggleMenu : '';
if ($this->searchMenu) {
$options = ArrayHelper::merge(['url' => '', 'method' => 'GET', 'name' => 'keyword', 'placeholder' => '搜索'], $this->searchMenu);
echo strtr($this->_searchTemplate, ['{action}' => Url::to($options['url']), '{method}' => $options['method'], '{name}' => $options['name'], '{placeholder}' => $options['placeholder']]);
}
parent::run();
echo Html::endTag('ul');
echo Html::endTag('div');
echo Html::endTag('div');
}
示例9: run
public function run()
{
$this->items = $this->getMenuItems();
parent::run();
}
示例10: run
public function run()
{
parent::run();
$this->itemOffset = 0;
}
示例11: run
public function run()
{
$this->registerScript();
parent::run();
}
示例12: run
public function run()
{
$view = $this->getView();
LangSwitcherAsset::register($view);
parent::run();
}