牛骨文教育服务平台(让学习变的简单)
博文笔记

Yii2设置网页标题

创建时间:2014-08-25 投稿人: 浏览次数:8507

在Yii2中,页面标题是View类的一个公有成员(public)变量$title。

要设置页面标题,首先在Controller/Action中设置$title的值,

TestController {
	public funtion actionIndex() {
		...
		$this->getView()->title = "your title";
		return $this->render("index");
	}
}

然后可以在layout中设置页面标题:

<title><?= Html::encode($this->title)."-踏得网云开发平台" ?></title>

by iefreer
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。