Introduction to Template
Template has been verified to work with CodeIgniter 1.7
Template is right for you if:
- You feel like using views can be clunky, especially when "embedding" views.
- You don't like calling header, footer, and other global views from every Controller method.
- You prefer having one "master template" that can be changed for any controller in order to meet unique application design needs.
- You don't want to drastically alter the way you interface controllers and views.
- You like clear, thorough documentation on par with CodeIgniter's User Guide.
What's New in Version 1.4.1?
Version 1.4.1 is mostly a maintenance release, fixing comment and documentation typos. In addition, the 1.4.1 download now ships with its documentation. And finally, the Template class was renamed to work more like a core library so you can extend/overload/replace it in your application libraries folder, among other things.
Template works by writing to pre-defined regions of a master template. Although you will most often write to your template from a Controller, you can write content to these regions from any part of your application. Content could be a simple string of plain text, HTML, or the results from a View. Regions display by echoing variables placed throughout your master template as desired. Template also lets you use multiple template configurations, making it completely flexible to meet the needs of your application’s design.
Here's what using template looks like:
$this->template->write('title', 'Introduction to Template');
$this->template->write_view('content', 'blog/posts', $this->blog->get_posts());
Look interesting? Head over to the Getting Started section to begin using Template in your next CodeIgniter application.