main.php 1.68 KB
Newer Older
1
<?php
2
use frontend\config\AppAsset;
3
use yii\helpers\Html;
Alexander Makarov committed
4 5
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
6
use yii\widgets\Breadcrumbs;
7
use frontend\widgets\Alert;
8 9 10 11 12

/**
 * @var $this \yii\base\View
 * @var $content string
 */
13
AppAsset::register($this);
14 15 16 17 18
?>
<?php $this->beginPage(); ?>
<!DOCTYPE html>
<html lang="en">
<head>
Alexander Makarov committed
19 20
	<meta charset="<?= Yii::$app->charset ?>"/>
	<title><?= Html::encode($this->title) ?></title>
21 22 23 24
	<?php $this->head(); ?>
</head>
<body>
	<?php $this->beginBody(); ?>
Alexander Makarov committed
25
	<?php
26
		NavBar::begin([
Alexander Makarov committed
27 28
			'brandLabel' => 'My Company',
			'brandUrl' => Yii::$app->homeUrl,
29
			'options' => [
Alexander Makarov committed
30
				'class' => 'navbar-inverse navbar-fixed-top',
31 32 33 34 35 36 37
			],
		]);
		$menuItems = [
			['label' => 'Home', 'url' => ['/site/index']],
			['label' => 'About', 'url' => ['/site/about']],
			['label' => 'Contact', 'url' => ['/site/contact']],
		];
Alexander Makarov committed
38
		if (Yii::$app->user->isGuest) {
39 40
			$menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']];
			$menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
Alexander Makarov committed
41
		} else {
42
			$menuItems[] = ['label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => ['/site/logout']];
Alexander Makarov committed
43
		}
44 45
		echo Nav::widget([
			'options' => ['class' => 'navbar-nav pull-right'],
Alexander Makarov committed
46
			'items' => $menuItems,
47
		]);
Alexander Makarov committed
48 49
		NavBar::end();
	?>
50

Alexander Makarov committed
51
	<div class="container">
52
	<?=Breadcrumbs::widget([
53 54
		'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
	]); ?>
55
	<?=Alert::widget()?>
Alexander Makarov committed
56
	<?= $content ?>
Alexander Makarov committed
57
	</div>
58

Alexander Makarov committed
59 60
	<footer class="footer">
		<div class="container">
Alexander Makarov committed
61 62
		<p class="pull-left">&copy; My Company <?= date('Y') ?></p>
		<p class="pull-right"><?= Yii::powered() ?></p>
Alexander Makarov committed
63 64
		</div>
	</footer>
65 66 67 68 69

	<?php $this->endBody(); ?>
</body>
</html>
<?php $this->endPage(); ?>