[eluser]Twisted1919[/eluser]
Hi there , i don't know if i'm doing this in the right way , but here is my situation .
I have MY_Controller , which in its constructor checks if the site is online or under maintenance , as follows :
Code:
class MY_Controller extends Controller{
public function __construct()
{
parent::Controller();
$this->get_site_status();
}
protected function get_site_status()
{
if($this->config->item('site_online') == FALSE)
{
show a custom page here .
}
}
Ok , now i thought that if i cand duplicate the show_error() function and change it a bit would feet my needs , so i tried to extend the Exceptions class as follows:
Code:
class MY_Exceptions extends CI_Exceptions{
public function __construct()
{
parent::CI_Exceptions();
}
public function show_maintenance($template = 'maintenance', $status_code = 500)
{
set_status_header($status_code);
if (ob_get_level() > $this->ob_level + 1)
{
ob_end_flush();
}
ob_start();
include(APPPATH.'errors/'.$template.EXT);
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
But when i try to load it , it says :
Fatal error: Class 'CI_Exceptions' not found in C:\wamp\www\ci\system\application\libraries\MY_Exceptions.php on line 8
So why this isn't working ?
I ended up by doing
Code:
class MY_Controller extends Controller{
public function __construct()
{
parent::Controller();
$this->get_site_status();
}
public function get_site_status()
{
if($this->config->item('site_online') == FALSE)
{
$error =& load_class('Exceptions');
echo $error->show_error($this->config->item('site_name'), $this->config->item('site_offline_message'), 'maintenance', 200);
exit;
}
}
How correct is that ?
Any suggestions on doing this in the right way ?
Thank you .