I am new to Yii and I am trying to implement materialize in this framework. Run but the login tap does not appear in the navigation bar to see if someone could help me and tell me how to solve the problem. I would really appreciate it if someone can help me. The problem is after (Yii::$app->user->isGuest)
.
<?php
/* @var $this \yii\web\View */
/* @var $content string */
use backend\assets\AppAsset;
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use common\widgets\Alert;
use yii\helpers\Url;
AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php // echo Html::csrfMetaTags() ?>
<!-- <title><?php // echo Html::encode($this->title) ?></title> -->
<?php //echo $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<!DOCTYPE html>
<head>
<meta charset = "<?= Yii::$app->charset ?>"
<?= Html::csrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<header>
<nav>
<div class="nav-wrapper">
<div class = "col s12">
<a href = "<?=Yii::$app->homeUrl ?>" class= "brand-logo"><?= Yii::$app->name ?></a>
<ul id = "nav-mobile" class = "right hide-on-med-and-down">
<li><a href = "<?= Url::toRoute("site/index") ?>">Home</a></li>
<li>
<?php // echo (Yii::$app -> user_>isGuest)? '<a href= " "'.Url::to('index.php?r=user/site/login').'">Login</a>' : '<a href= " "'.Url::to('index.php?r=reports/reports/index').'">Reports</a>';
if (Yii::$app->user->isGuest) {
$menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
} else {
$menuItems[] = ['label' => 'Reports', 'url' => ['/reports/index']];
$menuItems[] = '<li>'
. Html::beginForm(['/site/logout'], 'post')
. Html::submitButton(
'Logout (' . Yii::$app->user->identity->username . ')',
['class' => 'btn btn-link logout']
)
. Html::endForm()
. '</li>';
}
?>
</li>
</ul>
</div>
</div>
</nav>
</header>
</body>
</html>
<!-- ter new -->
<main>
<!-- <div class="container"> -->
<?= Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]) ?>
<?= Alert::widget() ?>
<?= $content ?>
<!-- </div> -->
<!-- </div> -->
</main>
<footer class="footer">
<div class="container">
<p class="pull-left">© <?= Html::encode(Yii::$app->name) ?> <?= date('Y') ?></p>
<p class="pull-right"><?= Yii::powered() ?></p>
</div>
</footer>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>