在 yii2 中将标题页设置为 h1
set title page to h1 in yii2
在 yii2 中将标题页设置为 h1?
可见:
$this->title = 'title' ;
和源代码:
<title>title</title>
在视图中,该值被分配给 $this->title 以供在 head 中使用,如果在用户视图中有用
<?php
$this->title = $model->id;
?>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My Title </title> <!-- this is for SEO -->
...
</head>
<body>
<h1><?= $this->title ?> </h1> <!-- this is for user view -->
正在设置标题变量。示例:
$this->title = $model->id; //Set title
然后在视图或布局文件中使用标题变量。示例:
Html::encode($this->title)
<?php
# PHP code...
use yii\helpers\Html;
use app\assets\AppAsset;
AppAsset::register($this); //register an asset bundle
?>
<?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">
<?= Html::csrfMetaTags() ?> <!-- // CSRF -->
<title><?= Html::encode($this->title) ?></title> <!-- for Page and Seo -->
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<div class="wrap">
<?= $content ?> <!-- # view file:<h1> or... #Html::encode($this->title)-->
</div>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
在 yii2 中将标题页设置为 h1?
可见:
$this->title = 'title' ;
和源代码:
<title>title</title>
在视图中,该值被分配给 $this->title 以供在 head 中使用,如果在用户视图中有用
<?php
$this->title = $model->id;
?>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My Title </title> <!-- this is for SEO -->
...
</head>
<body>
<h1><?= $this->title ?> </h1> <!-- this is for user view -->
正在设置标题变量。示例:
$this->title = $model->id; //Set title
然后在视图或布局文件中使用标题变量。示例:
Html::encode($this->title)
<?php
# PHP code...
use yii\helpers\Html;
use app\assets\AppAsset;
AppAsset::register($this); //register an asset bundle
?>
<?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">
<?= Html::csrfMetaTags() ?> <!-- // CSRF -->
<title><?= Html::encode($this->title) ?></title> <!-- for Page and Seo -->
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<div class="wrap">
<?= $content ?> <!-- # view file:<h1> or... #Html::encode($this->title)-->
</div>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>