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

/**
10 11
 * @var \yii\web\View $this
 * @var string $content
12
 */
13
AppAsset::register($this);
14 15 16
?>
<?php $this->beginPage(); ?>
<!DOCTYPE html>
17
<html lang="<?= Yii::$app->language ?>">
18
<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
		echo Nav::widget([
Qiang Xue committed
45
			'options' => ['class' => 'navbar-nav navbar-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
		'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
54 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(); ?>