I'm creating a website with CodeIgniter & have a question on best practice.
I generally break my webpages up into modular chunks. Header, Content, Footer (and some other stuff sprinkled in between as needed.
The 'Header' and 'Footer' chunks are usually static, while the guts in between can change depending on a few variables (the actual page for example - home, about, contact etc.)
Below is the controller for the page. header_view, navigation_view, and footer_view will (most likely) never change. The home_main_view will.
public function index()
{
$this->load->view('header_view');
$this->load->view('navigation_view');
$this->load->view('home_main_view');
$this->load->view('footer_view');
}
If a user navigates to the about page for example, the views may look something like this:
public function index()
{
$this->load->view('header_view');
$this->load->view('navigation_view');
$this->load->view('about_view');
$this->load->view('footer_view');
}
How would I handle that change in CI? Is it best to make home_main_view a variable and pass is into the index() function? I've done this before (user clicks a link that triggers a function in the controller that sets $var that calls index($var) that calls view($var).