-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GhostMenu usage not clear #40
Comments
Hi, use GhostNav =) |
No effect, looks exactly the same. <?php
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use yii\widgets\Menu;
use app\assets\AppAsset;
use webvimark\modules\UserManagement\components\GhostMenu;
use webvimark\modules\UserManagement\components\GhostNav;
use webvimark\modules\UserManagement\UserManagementModule;
/* @var $this \yii\web\View */
/* @var $content string */
AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?= Html::csrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<div class="wrap">
<?php
// NavBar::begin([
// 'brandLabel' => 'My Company',
// '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']],
// 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();
?>
<?php
GhostNav::begin([
//'brandLabel' => 'My Company',
//'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar-inverse navbar-fixed-top',
],
]);
echo GhostMenu::widget([
'encodeLabels'=>false,
'activateParents'=>true,
'items' => [
[
'label' => 'Backend routes',
'items'=>UserManagementModule::menuItems()
],
[
'label' => 'Frontend routes',
'items'=>[
['label'=>'Login', 'url'=>['/user-management/auth/login']],
['label'=>'Logout', 'url'=>['/user-management/auth/logout']],
['label'=>'Registration', 'url'=>['/user-management/auth/registration']],
['label'=>'Change own password', 'url'=>['/user-management/auth/change-own-password']],
['label'=>'Password recovery', 'url'=>['/user-management/auth/password-recovery']],
['label'=>'E-mail confirmation', 'url'=>['/user-management/auth/confirm-email']],
],
],
],
]);
GhostNav::end();
?>
<div class="container">
<?= Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]) ?>
<?= $content ?>
</div>
</div>
<footer class="footer">
<div class="container">
<p class="pull-left">© My Company <?= date('Y') ?></p>
<p class="pull-right"><?= Yii::powered() ?></p>
</div>
</footer>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?> |
It should be like this <?php
NavBar::begin([
//'brandLabel' => 'My Company',
//'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar-inverse navbar-fixed-top',
],
]);
echo GhostNav::widget([
'encodeLabels'=>false,
'activateParents'=>true,
'items' => [
[
'label' => 'Backend routes',
'items'=>UserManagementModule::menuItems()
],
[
'label' => 'Frontend routes',
'items'=>[
['label'=>'Login', 'url'=>['/user-management/auth/login']],
['label'=>'Logout', 'url'=>['/user-management/auth/logout']],
['label'=>'Registration', 'url'=>['/user-management/auth/registration']],
['label'=>'Change own password', 'url'=>['/user-management/auth/change-own-password']],
['label'=>'Password recovery', 'url'=>['/user-management/auth/password-recovery']],
['label'=>'E-mail confirmation', 'url'=>['/user-management/auth/confirm-email']],
],
],
],
]);
NavBar::end();
?> |
OK, GhostNav is just the same Nav widget. Only thing it does is hiding links that is unavailable for current user. If you want bootstrap menu, then do the following:
|
Ok, I thought it will make two properly stylized drop-down menus. |
You are welcome =) |
@FreezeS |
Hello,
I'm trying to use the GhostMenu widget as a navbar in the main layout but the layout is wrong.
I replaced the old navbar with calls to NavBar::begin(), echo GhostMenu::widget..., NavBar::end().
Maybe I'm missing something from the documentation but it should be updated to clarify this issue.
The text was updated successfully, but these errors were encountered: