[eluser]mattbman[/eluser]
This is a question for those that have worked with the framework for a while, just asking on opinions regarding the best practice to accomplish what I need.
I have a block of code that I want as a header and footer on all of my pages (multiple controllers), and I am struggling as to what the best way to go about putting that in the framework. Here is what I've come up with so far:
1. Hooks using pre_controller and post_controller - this seems to work well if it is a simple block of HTML text, however my header also needs to get access to the session information to display whether a person is logged in or not. The class for the hook doesn't seem to like $CI =& get_instance();, so I have trouble loading any libraries within that hook class
2. Extend the controller to MY_controller and include my header and footer functions there. - I don't mind this as a solution, but I would need to add 2 lines of code to every page function. Is there a way to make this call the site header and footer automatically?
3. Create a model that will output the header and footer. - I am still in the same situation as #2 on this one, that I would have to call the functions for that model on every output function so that it will display.
What has worked for you guys? Is there some idea that I am missing?
Thanks