gpt4 book ai didi

yii2 - 我如何使用yii2将侧边栏菜单放在右侧

转载 作者:行者123 更新时间:2023-12-04 02:48:52 26 4
gpt4 key购买 nike

我正在使用 yii2 开发在线应用程序。我想在我的应用程序中使用侧边栏菜单。我该如何创建?我只有导航栏菜单。我想要右侧的侧边栏菜单。`

  NavBar::begin([
'brandLabel' => 'Civil Department',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar-inverse navbar-fixed-top',
],
]);
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => [
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']],

['label' => 'ApplicationsForms', 'url' => ['/site/index'],
'items' => [

['label' => 'Casual Leave', 'url' => ['casual-leaves/create']],
['label' => 'Mtech Leave', 'url' => ['mtech-leave/create']],
['label' => 'Phd Leave', 'url' => ['phd-leave/create']],
['label' => 'Duty Leave', 'url' => ['duty-leave/create']],

],'visible' => Yii::$app->user->isGuest // && Yii::$app->user->identity->level == Usertable::level1,

],
['label' => 'Leave Applications', 'url' => ['/site/index'],
'items' => [

['label' => 'Applications for casual leave', 'url' => ['casual-leaves/index']],
['label' => 'Applications for Mtech leave', 'url' => ['mtech-leave/index']],
['label' => 'Applications for Phd leave', 'url' => ['phd-leave/index']],
['label' => 'Applications for Duty leave', 'url' => ['duty-leave/index']],

],'visible' => !Yii::$app->user->isGuest // && Yii::$app->user->identity->level == Usertable::level1,

],
Yii::$app->user->isGuest ?
['label' => 'Login', 'url' => ['/site/login']] :
[
'label' => 'Logout (' . Yii::$app->user->identity->username . ')',
'url' => ['/site/logout'],
'linkOptions' => ['data-method' => 'post']
],
],
]);
NavBar::end();
?>

这是我的导航栏菜单。我该怎么做才能获得侧边栏菜单。我想重新安排导航栏。那就是我尝试将所有请假申请放到侧边栏中。

Composer .json

  "name": "yiisoft/yii2-app-basic",
"description": "Yii 2 Basic Project Template",
"keywords": ["yii2", "framework", "basic", "project template"],
"homepage": "http://www.yiiframework.com/",
"type": "project",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?state=open",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"minimum-stability": "stable",
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": ">=2.0.5",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*",
"kartik-v/yii2-widgets": "dev-master"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",
"yiisoft/yii2-debug": "*",
"yiisoft/yii2-gii": "*",
"yiisoft/yii2-faker": "*",

},
"config": {
"process-timeout": 1800
},
"scripts": {
"post-create-project-cmd": [
"yii\\composer\\Installer::postCreateProject"
]
},
"extra": {
"yii\\composer\\Installer::postCreateProject": {
"setPermission": [
{
"runtime": "0777",
"web/assets": "0777",
"yii": "0755"
}
],
"generateCookieValidationKey": [
"config/web.php"
]
},
"asset-installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
}

这是正确的我只添加这一行“kartik-v/yii2-widgets”:“dev-master”任何其他安装过程

最佳答案

最简单的解决方案是使用如下扩展:http://demos.krajee.com/widget-details/sidenav

对于固定的 sidenav,您可以定义适当的布局,或者您可以在页面中添加 sidenav .. 就像这个示例

use yii\helpers\Url;  // this is for Class URL ******
use kartik\widgets\SideNav;


$menuItems[] = ['label' => 'DFenX - Yii2 User - '. Yii::t('app','User Admin Panel'), 'icon' => 'cog', 'url'=>Url::to(['/user/admin/index'])];
$menuItems[] = ['label' => Yii::t('app','Authentication manager'), 'icon' => 'th-list', 'items' => [
['label' => 'Settings', 'icon' => 'th-list', 'items' => [
['label' => '/user/settings', 'url'=>Url::to(['/user/settings'])],
['label' => '/user/settings/profile', 'url'=>Url::to(['/user/settings/profile'])],
['label' => '/user/settings/account', 'url'=>Url::to(['user/settings/account'])],
['label' => '/user/settings/networks', 'url'=>Url::to(['/user/settings/networks'])],
]],
['label' => 'Registration', 'icon' => 'th-list', 'items' => [
['label' => '/user/registration/register', 'url'=>Url::to(['/user/registration/register'])],
['label' => '/user/registration/resend', 'url'=>Url::to(['/user/registration/resend'])],
]],
['label' => 'Security', 'icon' => 'th-list', 'items' => [
['label' => '/user/security/login', 'url'=>Url::to(['/user/security/login'])],
['label' => '/user/security/logout', 'url'=>Url::to(['/user/security/logout'])],
]],
['label' => 'Recovery', 'icon' => 'th-list', 'items' => [
['label' => '/user/recovery/request', 'url'=>Url::to(['/user/recovery/request'])],
['label' => '/user/recovery/reset', 'url'=>Url::to(['/user/recovery/reset'])],
]],
]];

$type = SideNav::TYPE_PRIMARY;
$heading = '<i class="glyphicon glyphicon-user"></i> ' . Yii::t('app','USER Admin - UTILITIES');

echo SideNav::widget([
'type' => $type,
'encodeLabels' => false,
'heading' => $heading,
'items' =>$menuItems,
]);

有关安装,请参阅 https://github.com/kartik-v/yii2-widgetshttp://www.yiiframework.com/extension/yii2-widgets

关于yii2 - 我如何使用yii2将侧边栏菜单放在右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35692146/

26 4 0