Fix #267: Adjust main layout for Bootstrap5 (#268)

This commit is contained in:
Anton 2022-08-19 00:57:02 +03:00 committed by GitHub
parent 27e20ee60e
commit e35ea2e814
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,28 +11,30 @@ use yii\bootstrap5\Nav;
use yii\bootstrap5\NavBar; use yii\bootstrap5\NavBar;
AppAsset::register($this); AppAsset::register($this);
$this->registerCsrfMetaTags();
$this->registerMetaTag(['charset' => Yii::$app->charset], 'charset');
$this->registerMetaTag(['name' => 'viewport', 'content' => 'width=device-width, initial-scale=1, shrink-to-fit=no']);
$this->registerMetaTag(['name' => 'description', 'content' => $this->params['meta_description'] ?? '']);
$this->registerMetaTag(['name' => 'keywords', 'content' => $this->params['meta_keywords'] ?? '']);
$this->registerLinkTag(['rel' => 'icon', 'type' => 'image/x-icon', 'href' => '@web/favicon.ico']);
?> ?>
<?php $this->beginPage() ?> <?php $this->beginPage() ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>" class="h-100"> <html lang="<?= Yii::$app->language ?>" class="h-100">
<head> <head>
<meta charset="<?= Yii::$app->charset ?>">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<?php $this->registerCsrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title> <title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?> <?php $this->head() ?>
</head> </head>
<body class="d-flex flex-column h-100"> <body class="d-flex flex-column h-100">
<?php $this->beginBody() ?> <?php $this->beginBody() ?>
<header> <header id="header">
<?php <?php
NavBar::begin([ NavBar::begin([
'brandLabel' => Yii::$app->name, 'brandLabel' => Yii::$app->name,
'brandUrl' => Yii::$app->homeUrl, 'brandUrl' => Yii::$app->homeUrl,
'options' => [ 'options' => ['class' => 'navbar-expand-md navbar-dark bg-dark fixed-top']
'class' => 'navbar navbar-expand-md navbar-dark bg-dark fixed-top',
],
]); ]);
echo Nav::widget([ echo Nav::widget([
'options' => ['class' => 'navbar-nav'], 'options' => ['class' => 'navbar-nav'],
@ -40,38 +42,38 @@ AppAsset::register($this);
['label' => 'Home', 'url' => ['/site/index']], ['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => ['/site/about']], ['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']], ['label' => 'Contact', 'url' => ['/site/contact']],
Yii::$app->user->isGuest ? ( Yii::$app->user->isGuest
['label' => 'Login', 'url' => ['/site/login']] ? ['label' => 'Login', 'url' => ['/site/login']]
) : ( : '<li class="nav-item">'
'<li>' . Html::beginForm(['/site/logout'])
. Html::beginForm(['/site/logout'], 'post', ['class' => 'form-inline']) . Html::submitButton(
. Html::submitButton( 'Logout (' . Yii::$app->user->identity->username . ')',
'Logout (' . Yii::$app->user->identity->username . ')', ['class' => 'nav-link btn btn-link logout']
['class' => 'btn btn-link logout'] )
) . Html::endForm()
. Html::endForm() . '</li>'
. '</li>' ]
)
],
]); ]);
NavBar::end(); NavBar::end();
?> ?>
</header> </header>
<main role="main" class="flex-shrink-0"> <main id="main" class="flex-shrink-0" role="main">
<div class="container"> <div class="container">
<?= Breadcrumbs::widget([ <?php if (!empty($this->params['breadcrumbs'])): ?>
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], <?= Breadcrumbs::widget(['links' => $this->params['breadcrumbs']]) ?>
]) ?> <?php endif ?>
<?= Alert::widget() ?> <?= Alert::widget() ?>
<?= $content ?> <?= $content ?>
</div> </div>
</main> </main>
<footer class="footer mt-auto py-3 text-muted"> <footer id="footer" class="mt-auto py-3 bg-light">
<div class="container"> <div class="container">
<p class="float-left">&copy; My Company <?= date('Y') ?></p> <div class="row text-muted">
<p class="float-right"><?= Yii::powered() ?></p> <div class="col-md-6 text-center text-md-start">&copy; My Company <?= date('Y') ?></div>
<div class="col-md-6 text-center text-md-end"><?= Yii::powered() ?></div>
</div>
</div> </div>
</footer> </footer>