[eluser]ToddyBoy[/eluser]
In my previous life of coding before I found CodeIgniter, I would use a lot of include statements for certain elements in a page, eg navigation, footer, etc. so I only had to change it once and have it applied to all pages with that file included.
Being new to MVC, I'm not sure how to go about doing something similar, especially when it comes to form validation and including snippets of code for stuff like blog post summaries, random testimonial quotes.
I've tried to use something like this in my controller
Code:
function index()
{
$data['query'] = $this->db->get('blog');
$this->load->view('blog/blog_header');
$this->load->view('blog/blog_excerpt', $data);
$this->load->view('blog/blog_footer');
}
What happens with form validation and recalling the same page with error messages? I tried doing the same as the example in the User Guide but it used one single view for the whole page whereas I use 3.
The other area I have trouble with is trying to get something like including a small snippet of code to display a random client testimonial, for example. In my previous life, I would use a PHP include statement and it would work. Would I do the same from inside the view that contains the content of the page or would I have a separate view for just the testimonial and place that above or below the content view?
An easy way to get around all of this would be to use a single view for each each 'page' but that seems to defeat the purpose of MVC and OOP.