介紹樣版(Template)

Template 已經能正常的在 CodeIgniter 1.7 版本運作

The Template library, written for the CodeIgniter PHP-framework, is a wrapper for CI’s View implementation. Template is a reaction to the numerous questions from the CI community regarding how one would display multiple views for one controller, and how to embed “views within views” in a standardized fashion. In addition, Template provides extra Views loading capabilities, the ability to utilize any template parser (like Smarty), and shortcuts for including CSS, JavaScript, and other common elements in your final rendered HTML.

如果下列情況是你遇到的,那麼Template正是你所需要的:

Ready to give Template a shot? Download it now and get started.

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.

下載版本 1.4.1

Template's Approach

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());
$this->template->render();

Look interesting? Head over to the Getting Started section to begin using Template in your next CodeIgniter application.

Template User Guide: