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 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');
    }

}

Clone this wiki locally