How to Program With Yii2: Exploring MVC, Forms and Layouts (ok)
https://code.tutsplus.com/tutorials/how-to-program-with-yii2-exploring-mvc-forms-and-layouts--cms-22682
<?php
/** @var yii\web\View $this */
/** @var string $content */
use app\assets\AppAsset;
use app\widgets\Alert;
use yii\bootstrap5\Breadcrumbs;
use yii\bootstrap5\Html;
use yii\bootstrap5\Nav;
use yii\bootstrap5\NavBar;
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' => Yii::getAlias('@web/favicon.ico')]);
?>
<?php $this->beginPage()?>
<!DOCTYPE html>
<html lang="<?=Yii::$app->language?>" class="h-100">
<head>
<title><?=Html::encode($this->title)?></title>
<?php $this->head()?>
</head>
<body class="d-flex flex-column h-100">
<?php $this->beginBody()?>
<header id="header">
<?php
NavBar::begin([
'brandLabel' => Yii::$app->name,
'brandUrl' => Yii::$app->homeUrl,
'options' => ['class' => 'navbar-expand-md navbar-dark bg-dark fixed-top'],
]);
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => [
['label' => 'Home', 'url' => ['/site/index']],
[
'label' => 'Status',
'items' => [
[
'label' => 'Create',
'url' => ['/status/create'],
],
],
],
['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']],
Yii::$app->user->isGuest ?
['label' => 'Login', 'url' => ['/site/login']] :
['label' => 'Logout (' . Yii::$app->user->identity->username . ')',
'url' => ['/site/logout'],
'linkOptions' => ['data-method' => 'post']],
],
]);
NavBar::end();
?>
</header>
<main id="main" class="flex-shrink-0" role="main">
<div class="container">
<?php if (!empty($this->params['breadcrumbs'])): ?>
<?=Breadcrumbs::widget(['links' => $this->params['breadcrumbs']])?>
<?php endif?>
<?=Alert::widget()?>
<?=$content?>
</div>
</main>
<footer id="footer" class="mt-auto py-3 bg-light">
<div class="container">
<div class="row text-muted">
<div class="col-md-6 text-center text-md-start">© My Company <?=date('Y')?></div>
<div class="col-md-6 text-center text-md-end"><?=Yii::powered()?></div>
</div>
</div>
</footer>
<?php $this->endBody()?>
</body>
</html>
<?php $this->endPage()?>C:\xampp74\htdocs\oectest\views\status\create.php
C:\xampp74\htdocs\oectest\views\status\view.php
C:\xampp74\htdocs\oectest\models\Status.php
C:\xampp74\htdocs\oectest\controllers\StatusController.php
PreviousGenerating Code with GiiNextHow to Program With Yii2: Working With the Database and Active Record (ok)
Last updated