Codeigniter easily integrates smarty

Source: Internet
Author: User
The template mechanism of smarty is very powerful. generally, CI does not need to integrate other template tags, because PHP itself is a label and is easy to use. Codeigniter integration smarty tutorial (I use the latest version): Step 1: Download codeign

The template mechanism of smarty is very powerful. generally, CI does not need to integrate other template tags, because PHP itself is a label and is easy to use. Codeigniter integration smarty tutorial (I use the latest version) as follows:
Step 1: Download the latest codeigniter: http://codeigniter.org.cn/downloads
Step 2: Download the smarty latest version: http://www.smarty.net/download
Step 3:
Configuration steps:
(1) copy the smarty to application/libraries, and create the templates, templates_c, config, and cache directories under the root directory. The structure is as follows:

(2) add a new entry FILE: define ('root', dirname (_ FILE __));
(3) Create CI_Smarty.php under libraries

 $ Value) {$ this-> $ key = $ value;} else {// ROOT is Codeigniter in the entry file index. root directory of the web application defined by php $ this-> template_dir = $ template_dir? $ Template_dir: ROOT. '/templates'; $ this-> compile_dir = $ compile_dir? $ Compile_dir: ROOT. '/templates_c'; $ this-> config_dir = $ config_dir? $ Config_dir: ROOT. '/config'; $ this-> cache_dir = $ cache_dir? $ Cache_dir: ROOT. '/cache ';}}}

Use in controller:
 load->library('CI_Smarty');        }                                public function test()        {                        $this->ci_smarty->assign('test', 'smarty');            $this->ci_smarty->display('test.tpl');                    }}/* End of file welcome.php *//* Location: ./application/controllers/welcome.php */

Create a test. tpl template:
    This is a {$ test} test

Test successful!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.