[eluser]Edemilson Lima[/eluser]
I still didn't figured out how to better define the structure of an application with Code Igniter... Before I was used to call PHP scripts within PHP scripts, using includes or requires. By this way, the first script loads the website main template and the sub scripts loads sub templates that are the blocks inside. For example, the main template have a header, an empty space and the footer. This empty space is then filled with a sub template, which can be the home or another sub page. Also the sub templates can have empty spaces that are filled with the contents.
Personally, I don't like to separate the header from the footer in different files, because if you open them in Dreamweaver, they will be unvalid HTML code. The header will not have closing tags and the footer will miss the opening tags. So, I like to put everything into the same file, and then inject the content using PHP include or require. By this way, I don't need to load the main template every time, in every sub page. The content is changed only changing few variables, which points to the filenames that will be loaded. So, PHP do the task automatically. In the sub pages I don't need to worry about headers and footers, they will be already there.
With CI, I got this placing a "$this->load->view($file);" into the main view. But this only allow me to load views inside views, not controllers inside controllers. When I do load a view inside another view, how do I generate dynamic content for the sub views?
Looking at the blog demo video, I understood that I will need to build the header and the footer in each function. Isn't there another better way to do that? I would like to see how is a big website, with lots of nested views was done with CI. Does somebody here know where can I download a sample?