模板继承与模板之间的相互调用
在控制器中单独定义父模板
public $layout = 'home';
public function actionIndex()
{
return $this->render('index');
}
在views文件夹下layouts文件夹写一个home.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Page Title</title>
</head>
<body>
<p style="color:red;">我是父模板</p>
<?=$content?> //通过此方法告诉继承文件的内容放在这里
</body>
</html>
模板相互调用
<?=$this->render('test');?>