Welcome Guest, Not a member yet? Register   Sign In
How Are Controllers Loaded?
#3

[eluser]Bart Mebane[/eluser]
@ShoeLace: Another way to accomplish what you're trying to do is to extend the base Controller class, as explained in the User Guide under Creating Core Classes. Create a class called MY_Controller (you can change the prefix in config.php), put it in your library folder as MY_Controller.php, and it will be loaded automatically. All of your controllers would then extend MY_Controller instead of Controller.

As a simplified example,
Code:
class MY_Controller extends Controller
{
    function __construct()
    {
        parent::__construct();
    }

    protected function _load_page($view, $vars = array(), $return = FALSE)
    {
        $output  = $this->load->view('header_view', $vars, $return);
        $output .= $this->load->view($view, $vars, $return);
        $output .= $this->load->view('footer_view', $vars, $return);
        return $output;
    }
}


Messages In This Thread
How Are Controllers Loaded? - by El Forum - 12-03-2010, 07:31 AM
How Are Controllers Loaded? - by El Forum - 12-03-2010, 07:45 AM
How Are Controllers Loaded? - by El Forum - 12-03-2010, 08:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB