main.php 1.6 KB

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