forked from bcit-ci/CodeIgniter
-
Notifications
You must be signed in to change notification settings - Fork 0
Chuck Son's take
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.
./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');
}
}