CI integration Smarty, cismarty_PHP tutorial

Source: Internet
Author: User
CI integrates Smarty and cismarty. CI integrates Smarty and cismarty1. download the smarty template to the corresponding site; 2. copy the libs directory in the source code to the libraries Directory of the project and change it to smarty3.03. integrate Smarty and cismarty in the libr CI of the Project directory

1. download the smarty template from the corresponding site;

2. copy the libs directory in the source code to the libraries Directory of the project and change it to smarty3.0.

3. create the ci_smarty.php file in the libraries folder of the project directory. the content in the file is as follows:

Defined ('basepath') OR exit ('no direct script access allowed ');
Require_once (APPPATH. 'libraries/smarty3.0/Smarty. class. php ');
Class ci_smarty extends Smarty
{
Protected $ ci;
Public function _ construct (){
$ This-> ci = & get_instance ();
$ This-> ci-> load-> config ('smarty '); // load the smarty configuration file
// Obtain related configuration items
$ This-> template_dir = $ this-> ci-> config-> item ('Template _ dir ');
$ This-> complie_dir = $ this-> ci-> config-> item ('compile _ dir ');
$ This-> cache_dir = $ this-> ci-> config-> item ('cache _ dir ');
$ This-> config_dir = $ this-> ci-> config-> item ('config _ dir ');
$ This-> template_ext = $ this-> ci-> config-> item ('Template _ ext ');
$ This-> caching = $ this-> ci-> config-> item ('caching ');
$ This-> cache_lifetime = $ this-> ci-> config-> item ('lefttime ');
}
}

4. create the smarty. php file in the config folder of the project directory. the content is as follows:

5. create a folder templates_c in the directory where the file is located.

6. add the autoload. php file to the configuration folder of the project.

$ Autoload ['libraries'] = array ('ci _ smarty ');

7. create the file MY_Controller.php in the core folder of the project directory as follows: // extend the core control class.

8. test

Controller

View

Step 1. download the smarty template from the corresponding site; 2. copy the libs directory in the source code to the libraries Directory of the project and change it to smarty3.0. 3. in the libr Directory of the project...

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.