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

[eluser]ShoeLace1291[/eluser]
I realize that there must be several files or more that are involved in displaying the requested controller function. I was wondering what file primarily displays a controller function's content so I can hack it. I want to be able to find where the function is called so I can display global templates before and after the controller content.(header and footers).
#2

[eluser]vitoco[/eluser]
Instead of "hacking" the base system, use a feature called Hooks. This one makes "points" in the execution of the framework for you to execute your own code. In your case i guess it's post_controller_contructor and post_controller hooks

HOOKS

Saludos
#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;
    }
}




Theme © iAndrew 2016 - Forum software by © MyBB