main.php 1.7 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\base\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="<?php echo Yii::$app->charset; ?>"/>
  17. <title><?php echo Html::encode($this->title); ?></title>
  18. <?php $this->head(); ?>
  19. </head>
  20. <body>
  21. <?php $this->beginBody(); ?>
  22. <?php
  23. NavBar::begin(array(
  24. 'brandLabel' => 'My Company',
  25. 'brandUrl' => Yii::$app->homeUrl,
  26. 'options' => array(
  27. 'class' => 'navbar-inverse navbar-fixed-top',
  28. ),
  29. ));
  30. echo Nav::widget(array(
  31. 'options' => array('class' => 'navbar-nav pull-right'),
  32. 'items' => array(
  33. array('label' => 'Home', 'url' => array('/site/index')),
  34. array('label' => 'About', 'url' => array('/site/about')),
  35. array('label' => 'Contact', 'url' => array('/site/contact')),
  36. Yii::$app->user->isGuest ?
  37. array('label' => 'Login', 'url' => array('/site/login')) :
  38. array('label' => 'Logout (' . Yii::$app->user->identity->username .')' ,
  39. 'url' => array('/site/logout'),
  40. 'linkOptions' => array('data-method' => 'post')),
  41. ),
  42. ));
  43. NavBar::end();
  44. ?>
  45. <div class="container">
  46. <?php echo Breadcrumbs::widget(array(
  47. 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : array(),
  48. )); ?>
  49. <?php echo $content; ?>
  50. </div>
  51. <footer class="footer">
  52. <div class="container">
  53. <p class="pull-left">&copy; My Company <?php echo date('Y'); ?></p>
  54. <p class="pull-right"><?php echo Yii::powered(); ?></p>
  55. </div>
  56. </footer>
  57. <?php $this->endBody(); ?>
  58. </body>
  59. </html>
  60. <?php $this->endPage(); ?>