October/Winter CMS插件开发之404页面处理

开发插件默认路由地址是无法触发404错误页的,这相当不利于SEO,修复方法:

function onStart(){
    $slug = $this->param('slug');
    $p = Julian\Products\Models\Product::where('slug', '=', $slug)->first();
    if(!$p)
    {
        $this->setStatusCode(404);
        return $this->controller->run('404');
    }   
}

Post Comment