yii2继承之前公共模板 创建新的模板
在控制器里面写上
/**
* 更改初始化模板
*
* @return string
*/
public function init()
{
$this->layout = 'main';
}
创建视图文件
mian.php 内容
<?php $this->beginContent('@app/views/layouts/main.php');?>
<?php
use yii\helpers\Url;
use common\layout\Html_COPY;
use common\helpers\Md5_sign;
use common\helpers\Html;
use artuns\common\Data_init;
?>
<?= $content ?>
<?=$this->endContent(); ?>