2015-05-02 10:23:42 10634次浏览 4条回答 0 悬赏 0 金钱

如题,输入图片说明

如图,我不想要头部和底部,这个错误页面是一个独立的页面,想做类似
$this->renderPartial('error')
渲染出来的页面

  • 回答于 2015-05-02 20:37 举报
    public function actionError(){
     $this->layout = '';
    
     ....
    
     $this->render('error');
    
    }
    
    , 觉得很赞
  • 回答于 2015-05-05 20:51 举报

    $this->layout = false

    觉得很赞
  • 回答于 2017-03-17 00:11 举报

    在Yii2.0版本的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>
    
    觉得很赞
  • 回答于 2017-06-24 11:26 举报

    shABby

您需要登录后才可以回答。登录 | 立即注册
tgy3300
见习主管

tgy3300

注册时间:2015-03-20
最后登录:2018-09-12
在线时长:19小时53分
  • 粉丝4
  • 金钱10
  • 威望10
  • 积分300

热门问题