Comments (8)
Hi, use GhostNav =)
from user-management.
No effect, looks exactly the same.
This is my layout:
<?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() ?>
from user-management.
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();
?>
from user-management.
Ok, now it resembles a menu:
Is that how it's supposed to look?
from user-management.
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:
- start from basic Yii2 example
- replace Nav with GhostNav
- Add links that you want to see in your menu
from user-management.
Ok, I thought it will make two properly stylized drop-down menus.
I'll see what I can do next.
Thanks for the help :)
from user-management.
You are welcome =)
from user-management.
@FreezeS
add widget options 'options' => ['class' => 'navbar-nav navbar-right'],
from user-management.
Related Issues (20)
- access based on time HOT 1
- Model overwriting HOT 1
- how to stop auto logout? HOT 3
- Is this repository discontinued? HOT 2
- migration failed... HOT 4
- PHP 7.3 compact() issues an E_NOTICE level error HOT 1
- only one login per device can active in one time
- mySQL errors
- DB error when overwriting table names
- How to disable captcha on user registration?
- Migration not working for OCI HOT 2
- hasRole() function doesnt work with children roles
- GhostAccessControl::rules does not exist
- How to combine ghost-access with custom permissions
- $throwException is missing HOT 2
- Issue with Unchecked Routes in Permissions
- PHP Notice on permissions save for PHP 7.4 HOT 3
- Broken Link in FAQs section HOT 1
- Password recovery HOT 1
- compact(): Undefined variable: throwException while saving permission
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from user-management.