KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
What's the best way for constructing headers, and footers? Should you call it all from the controller, or include it from the view file? I'm using CodeIgniter, and I'm wanting to know what's the best practice for this. Loading all the included view files from the controller, like this? class Page extends Controller { function index() { $data['page_title'] = 'Your title'; $this->load->view('header'); $this->load->view('menu'); $this->load->view('content', $data); $this->load->view('footer'); } } or calling the single view file, and calling the header and footer views from there: //controller file class Page extends Controller { function index() { $data['page_title'] = 'Your title'; $this->load->view('content', $data); } } //view file <?php $this->load->view('header'); ?> <p>The data from the controller</p> <?php $this->load->view('footer'); ?> I've seen it done both ways, but want to choose now before I go too far down a path.
Tags (comma-separated)
Save Edits
Cancel