|
1 | 1 | <?php |
| 2 | + |
2 | 3 | use app\widgets\Alert; |
3 | 4 | use kartik\alert\AlertBlock; |
4 | 5 | use yii\helpers\Html; |
5 | 6 | use yii\bootstrap\Nav; |
6 | 7 | use yii\bootstrap\NavBar; |
7 | 8 | use yii\widgets\Breadcrumbs; |
8 | 9 | use app\assets\AppAsset; |
| 10 | + |
9 | 11 | /* @var $this \yii\web\View */ |
10 | 12 | /* @var $content string */ |
| 13 | + |
11 | 14 | AppAsset::register($this); |
12 | 15 | ?> |
13 | 16 | <?php $this->beginPage() ?> |
14 | | - <!DOCTYPE html> |
15 | | - <html lang="<?php echo Yii::$app->language; ?>"> |
16 | | - <head> |
17 | | - <meta charset="<?php echo Yii::$app->charset; ?>"/> |
18 | | - <meta name="viewport" content="width=device-width, initial-scale=1"> |
19 | | - <?php echo Html::csrfMetaTags(); ?> |
20 | | - <title><?php echo Html::encode($this->title); ?></title> |
21 | | - <?php $this->head() ?> |
22 | | - </head> |
23 | | - <body> |
24 | | - <?php $this->beginBody() ?> |
25 | | - <?php echo AlertBlock::widget([ |
26 | | - 'type' => AlertBlock::TYPE_GROWL, |
27 | | - 'useSessionFlash' => true, |
28 | | - 'delay' => false |
| 17 | +<!DOCTYPE html> |
| 18 | +<html lang="<?php echo Yii::$app->language; ?>"> |
| 19 | +<head> |
| 20 | + <meta charset="<?php echo Yii::$app->charset; ?>"/> |
| 21 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 22 | + <?php echo Html::csrfMetaTags(); ?> |
| 23 | + <title><?php echo Html::encode($this->title); ?></title> |
| 24 | + <?php $this->head() ?> |
| 25 | +</head> |
| 26 | +<body> |
| 27 | +<?php $this->beginBody() ?> |
| 28 | +<?php echo AlertBlock::widget([ |
| 29 | + 'type' => AlertBlock::TYPE_GROWL, |
| 30 | + 'useSessionFlash' => true, |
| 31 | + 'delay' => false |
| 32 | +]); |
| 33 | +?> |
| 34 | +<div class="wrap"> |
| 35 | + <?php NavBar::begin([ |
| 36 | + 'brandLabel' => 'Yii2 Basic Template', |
| 37 | + 'brandUrl' => Yii::$app->homeUrl, |
| 38 | + 'options' => [ |
| 39 | + 'class' => 'navbar-inverse navbar-fixed-top', |
| 40 | + ], |
| 41 | + ]); |
| 42 | + $menuItems = [ |
| 43 | + ['label' => 'Home', 'url' => ['/site/index']], |
| 44 | + ['label' => 'About Us', 'url' => ['/about-us']], |
| 45 | + ['label' => 'Contact', 'url' => ['/site/contact']], |
| 46 | + ]; |
| 47 | + if (Yii::$app->user->isGuest) { |
| 48 | + $menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']]; |
| 49 | + $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']]; |
| 50 | + } else { |
| 51 | + $menuItems[] = ['label' => 'Administration', 'url' => ['/admin'], 'visible' => Yii::$app->getUser()->can('admin')]; |
| 52 | + $menuItems[] = '<li>' |
| 53 | + . Html::beginForm(['/site/logout'], 'post') |
| 54 | + . Html::submitButton( |
| 55 | + 'Logout (' . Yii::$app->user->identity->username . ')', |
| 56 | + ['class' => 'btn btn-link'] |
| 57 | + ) |
| 58 | + . Html::endForm() |
| 59 | + . '</li>'; |
| 60 | + } |
| 61 | + echo Nav::widget([ |
| 62 | + 'options' => ['class' => 'navbar-nav navbar-right'], |
| 63 | + 'items' => $menuItems, |
29 | 64 | ]); |
| 65 | + NavBar::end(); |
30 | 66 | ?> |
31 | | - <div class="wrap"> |
32 | | - <?php |
33 | | - NavBar::begin([ |
34 | | - 'brandLabel' => 'Yii2 Basic Template', |
35 | | - 'brandUrl' => Yii::$app->homeUrl, |
36 | | - 'options' => [ |
37 | | - 'class' => 'navbar-inverse navbar-fixed-top', |
38 | | - ], |
39 | | - ]); |
40 | | - echo Nav::widget([ |
41 | | - 'options' => ['class' => 'navbar-nav navbar-right'], |
42 | | - 'items' => [ |
43 | | - ['label' => 'Home', 'url' => ['/site/index']], |
44 | | - ['label' => 'About Us', 'url' => ['/about-us']], |
45 | | - ['label' => 'Contact', 'url' => ['/site/contact']], |
46 | | - ['label' => 'Signup', 'url' => ['/site/signup'], 'visible' => Yii::$app->user->isGuest], |
47 | | - ['label' => 'Login', 'url' => ['/site/login'], 'visible' => Yii::$app->user->isGuest], |
48 | | - ['label' => 'Administration', 'url' => ['/admin'], 'visible' => Yii::$app->getUser()->can('admin')], |
49 | | - ['label' => 'Logout', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post'], 'visible' => !Yii::$app->user->isGuest], |
50 | | - ], |
51 | | - ]); |
52 | | - NavBar::end(); |
53 | | - ?> |
54 | 67 |
|
55 | | - <div class="container"> |
56 | | - <?php echo Breadcrumbs::widget([ |
57 | | - 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], |
58 | | - ]); ?> |
59 | | - <?php echo $content; ?> |
60 | | - </div> |
| 68 | + <div class="container"> |
| 69 | + <?php echo Breadcrumbs::widget([ |
| 70 | + 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], |
| 71 | + ]); ?> |
| 72 | + <?php echo $content; ?> |
61 | 73 | </div> |
| 74 | +</div> |
62 | 75 |
|
63 | | - <footer class="footer"> |
64 | | - <div class="container"> |
65 | | - <p class="pull-left">© Yii2 Basic Template <?php echo date('Y'); ?></p> |
66 | | - <p class="pull-right"><?php echo \yii\widgets\Menu::widget([ |
67 | | - 'items' => [ |
68 | | - ['label' => 'Terms & Conditions', 'url' => ['/terms-and-conditions']], |
69 | | - ['label' => 'Privacy Policy', 'url' => ['/privacy-policy']], |
70 | | - ], |
71 | | - ]); |
72 | | - ?></p> |
73 | | - </div> |
74 | | - </footer> |
| 76 | +<footer class="footer"> |
| 77 | + <div class="container"> |
| 78 | + <p class="pull-left">© Yii2 Basic Template <?php echo date('Y'); ?></p> |
| 79 | + <p class="pull-right"><?php echo \yii\widgets\Menu::widget([ |
| 80 | + 'items' => [ |
| 81 | + ['label' => 'Terms & Conditions', 'url' => ['/terms-and-conditions']], |
| 82 | + ['label' => 'Privacy Policy', 'url' => ['/privacy-policy']], |
| 83 | + ], |
| 84 | + ]); |
| 85 | + ?> |
| 86 | + </p> |
| 87 | + </div> |
| 88 | +</footer> |
75 | 89 |
|
76 | | - <?php $this->endBody() ?> |
77 | | - </body> |
78 | | - </html> |
| 90 | +<?php $this->endBody() ?> |
| 91 | +</body> |
| 92 | +</html> |
79 | 93 | <?php $this->endPage() ?> |
0 commit comments