Home >Backend Development >PHP Tutorial >CI integrates Smarty, cismarty_PHP tutorial

CI integrates Smarty, cismarty_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 09:06:461020browse

CI integrates Smarty, cismarty

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 rename it to smarty3.0

3. Create a new file ci_smarty.php in the libraries folder of the project directory. The contents are 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 smarty configuration file
//Get related configuration items
$this->template_dir = $this->ci-> ;config->item('template_dir');
               $this->complie_dir                                                                                                                                                                        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 a new smart.php file in the config folder of the project directory. The content is as follows:

5. Create a new folder templates_c in the directory where the entry file is located

6. In the project configuration folder, add

to the autoload.php file

$autoload['libraries'] = array('ci_smarty');

7. Create a new file MY_Controller.php in the core folder of the project directory with the following content: // Extend the core control class

8. Test

In controller

In view

http://www.bkjia.com/PHPjc/1064066.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1064066.htmlTechArticleCI integrates Smarty, cismarty 1. Go to the corresponding site to download the smarty template; 2. Copy the libs directory in the source code Copy it to the libraries directory of the project and rename it to smarty3.0 3. In the libr of the project directory...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn