This is a very simple and very powerful way to create templates in a code player, which is also very flexible.
http://news.dice.com/2013/02/18/how-to-build-a-to-do-app-with-codeigniter/
Ignore the title, most of the lesson is about setting up templates in CI.
Please note that I was first introduced to this method from a Jeffrey tutorial on net.tutsplus.com They all deserve to be tested: http://net.tutsplus.com/sessions/codeigniter-from-scratch/
edit - ok, this is good enough for publishing. So, in the tutorial on the template.php page, you will see
$this->load->view($maincontent);
which is great. but it is much better:
// load your header views $templatefolder = 'beta/'; if(isset($content01)) $this->load->view($templatefolder.$content01); if(isset($content02)) $this->load->view($templatefolder.$content02); if(isset($content03)) $this->load->view($templatefolder.$content03); // load your footer views
so instead of calling the "maincontent" view, I added links to $ content1, $ content2, etc. Since we do if isset, none of them are required. this way you can easily send more than one view file to a template. Or not at all if you just show a message, etc. Also note that we have a template folder - this way you can easily reuse the template file for other website templates, even with the same content.
in your controller (similar to the tutorial) it will be
$data['content01'] = 'codeigniterrawks'; $data['content02'] = 'mypetlion'; // beta template $this->load->view( 'template_beta', $data );
notice how simple it is if I want to include the same view files in a different template
$data['content01'] = 'codeigniterrawks'; $data['content02'] = 'mypetlion'; // alpha template $this->load->view( 'template_alpha', $data );