我需要在所有页面中加载头部视图和脚部视图。但show_error
使用自己的完整模板。它在加载此模板后停止执行,因此如果我愿意,页脚甚至不会加载。
我应该重写这个方法还是有其他方法?
所以,我就是这样做的,而且效果非常好。我延长了CI_Exceptions
正如 Yan Berk 所建议的,但我能够使用get_instance
并加载我的视图。
class MY_Exceptions extends CI_Exceptions {
private $CI;
private $dist;
public function __construct() {
parent::__construct();
$this->CI =& get_instance();
$this->dist = $this->CI->config->item('dist');
}
function show_error($heading, $message, $template = 'error_general', $status_code = 500) {
$head_data = array("title"=>$this->dist['site_title'].": Error");
$head = $this->CI->load->view('head', $head_data, TRUE);
$body = $this->CI->load->view('error_body', $message, TRUE);
echo $head;
echo $body;
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)