Skip to content
World Wide Web Server edited this page Jul 4, 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 simply sandwiches those indeterminate views between the header and footer. Hooks are particularly helpful when modifying a library such as "Tank Auth" that has 5+ views you would otherwise have to individually pass as an argument to your master template.

./config/hooks.php:

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

post_controller hook file:

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

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

}

Clone this wiki locally