您的位置:首页 > 编程语言 > PHP开发

【Yii2.0.7】在advanced高级模板环境中:设置404自定义页面的方法!

2016-04-28 10:35 295 查看
在Yii2.0.7版本的advanced高级模板环境中:设置404自定义页面的方法!

1、frontend->config->main.php添加如下:

'errorHandler' => [
'errorAction' => 'site/error',
],

2、frontend->views->site->error.php中添加如下:(注:可以自行发挥制作更漂亮的404页面)

<?php

use yii\helpers\Html;

$this->title = $name;

$this->context->layout = false; //不使用布局

?>
<div class="site-error">

<h1><?= Html::encode($this->title) ?></h1>

<div class="alert alert-danger">
<?= nl2br(Html::encode($message)) ?>
</div>

</div>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息