開始使用樣版
尋找如何使用樣版的文件嗎?請翻閱「使用手冊」.
下載與安裝
- 下載樣版類別庫
- 下載內容包含三個檔案:
- /libraries/Template.php
移動此檔至你的 application 或 system /libraries/ 資料夾 - /config/template.php
移動此檔至你的 application /config/ 資料夾 我們將會在稍後講解這個檔案 - /views/template.php
移動此檔至你的 application /views/ 資料夾 (如果在你的 views/ 已經存在有相同的檔案名稱,你可以重新命名這個template.php檔案) 我們將會在稍後講解這個檔案
- /libraries/Template.php
- 注意: 如果你能確認你的application沒有相同名稱檔案,那麼你可以試著直接將壓縮檔解開至你的application目錄
- 現在你已準備完畢,開始使用樣版吧! 如何使用?
'Template' is a very generic library name. Why was it chosen?
Template was designed to read well when encountered throughout your application's code. While, yes, I could have come up with a unique, cutesy, silly name for Template, I feel such a move wouldn't be very beneficial for those who use it. Nor would it follow the clear naming standards used by core CodeIgniter classes (the whole "ignition/fire" metaphor pretty much only goes as far as the framework's name).
On that note, feel free to hack and rename Template to whatever best suits your application or preferences.
Is using Template better than using Views?
Not exactly. Using Template is a better way to use Views, or at least that's what it aims to be. Additionally, the use of Template does not alter the default functionality of CodeIgniter Views. You could have 8 Controller methods that use Template alongside 8 others that just use $this->load>view(). Along with a simple interface to template parsers and methods for handling JavaScript and CSS assets, Template is a great foundation for implementing a Templating Engine in your CodeIgniter application.