main.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /* @var $this \yii\web\View */
  3. /* @var $content string */
  4. use app\widgets\Alert;
  5. use yii\helpers\Html;
  6. use yii\bootstrap\Nav;
  7. use yii\bootstrap\NavBar;
  8. use yii\widgets\Breadcrumbs;
  9. use app\assets\AppAsset;
  10. AppAsset::register($this);
  11. ?>
  12. <?php $this->beginPage() ?>
  13. <!DOCTYPE html>
  14. <html lang="<?= Yii::$app->language ?>">
  15. <head>
  16. <meta charset="<?= Yii::$app->charset ?>">
  17. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  18. <meta name="viewport" content="width=device-width, initial-scale=1">
  19. <?php $this->registerCsrfMetaTags() ?>
  20. <title><?= Html::encode($this->title) ?></title>
  21. <?php $this->head() ?>
  22. </head>
  23. <body>
  24. <?php $this->beginBody() ?>
  25. <div class="wrap">
  26. <?php
  27. NavBar::begin([
  28. 'brandLabel' => Yii::$app->name,
  29. 'brandUrl' => Yii::$app->homeUrl,
  30. 'options' => [
  31. 'class' => 'navbar-inverse navbar-fixed-top',
  32. ],
  33. ]);
  34. echo Nav::widget([
  35. 'options' => ['class' => 'navbar-nav navbar-right'],
  36. 'items' => [
  37. ['label' => 'Home', 'url' => ['/site/index']],
  38. ['label' => 'About', 'url' => ['/site/about']],
  39. ['label' => 'Contact', 'url' => ['/site/contact']],
  40. Yii::$app->user->isGuest ? (
  41. ['label' => 'Login', 'url' => ['/site/login']]
  42. ) : (
  43. '<li>'
  44. . Html::beginForm(['/site/logout'], 'post')
  45. . Html::submitButton(
  46. 'Logout (' . Yii::$app->user->identity->username . ')',
  47. ['class' => 'btn btn-link logout']
  48. )
  49. . Html::endForm()
  50. . '</li>'
  51. )
  52. ],
  53. ]);
  54. NavBar::end();
  55. ?>
  56. <div class="container">
  57. <?= Breadcrumbs::widget([
  58. 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
  59. ]) ?>
  60. <?= Alert::widget() ?>
  61. <?= $content ?>
  62. </div>
  63. </div>
  64. <footer class="footer">
  65. <div class="container">
  66. <p class="pull-left">&copy; My Company <?= date('Y') ?></p>
  67. <p class="pull-right"><?= Yii::powered() ?></p>
  68. </div>
  69. </footer>
  70. <?php $this->endBody() ?>
  71. </body>
  72. </html>
  73. <?php $this->endPage() ?>