main.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. use yii\helpers\Html;
  3. use yii\bootstrap\Nav;
  4. use yii\bootstrap\NavBar;
  5. use yii\widgets\Breadcrumbs;
  6. /**
  7. * @var $this \yii\web\View
  8. * @var $content string
  9. */
  10. app\config\AppAsset::register($this);
  11. ?>
  12. <?php $this->beginPage(); ?>
  13. <!DOCTYPE html>
  14. <html lang="en">
  15. <head>
  16. <meta charset="<?= Yii::$app->charset ?>"/>
  17. <title><?= Html::encode($this->title) ?></title>
  18. <?php $this->head(); ?>
  19. </head>
  20. <body>
  21. <?php $this->beginBody(); ?>
  22. <?php
  23. NavBar::begin([
  24. 'brandLabel' => 'My Company',
  25. 'brandUrl' => Yii::$app->homeUrl,
  26. 'options' => [
  27. 'class' => 'navbar-inverse navbar-fixed-top',
  28. ],
  29. ]);
  30. echo Nav::widget([
  31. 'options' => ['class' => 'navbar-nav pull-right'],
  32. 'items' => [
  33. ['label' => 'Home', 'url' => ['/site/index']],
  34. ['label' => 'About', 'url' => ['/site/about']],
  35. ['label' => 'Contact', 'url' => ['/site/contact']],
  36. Yii::$app->user->isGuest ?
  37. ['label' => 'Login', 'url' => ['/site/login']] :
  38. ['label' => 'Logout (' . Yii::$app->user->identity->username .')' ,
  39. 'url' => ['/site/logout'],
  40. 'linkOptions' => ['data-method' => 'post']],
  41. ],
  42. ]);
  43. NavBar::end();
  44. ?>
  45. <div class="container">
  46. <?=Breadcrumbs::widget([
  47. 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
  48. ]); ?>
  49. <?= $content ?>
  50. </div>
  51. <footer class="footer">
  52. <div class="container">
  53. <p class="pull-left">&copy; My Company <?= date('Y') ?></p>
  54. <p class="pull-right"><?= Yii::powered() ?></p>
  55. </div>
  56. </footer>
  57. <?php $this->endBody(); ?>
  58. </body>
  59. </html>
  60. <?php $this->endPage(); ?>