Skip to content
Derek Jones edited this page Jul 5, 2012 · 9 revisions

Using Hooks for headers and footers is much more flexible than using a master template. A master template requires you to pass all possible rendered view outputs to its "contents" argument, while Hooks will simply sandwiches any and all possible views before appending the footer. Hooks are particularly helpful when modifying a library such as "Tank Auth" that has 5+ views you'd otherwise have to individually pass as arguments to your master template.

Example:

./config/hooks.php:

$hook['post_controller'] = array( 'class' => 'Template', 'function' => 'footer', 'filename' => 'template.php', 'filepath' => 'hooks' );

./hooks/template.php:

class Template extends Controller { function Template() { parent::Controller(); }

    function footer() {
            $this->load->view('footer_view');
    }

}

Also make sure to have the Hooks field set to TRUE in your master config file.

Clone this wiki locally