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. In the libraries folder of the project directory Create a new file ci_smarty.php with the following content:
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; ;load->config('smarty'); //Load smarty's configuration file
'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'); ;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 :
$autoload['libraries'] = array('ci_smarty' ; Medium
The above introduces CI integration with Smarty, including the require content. I hope it will be helpful to friends who are interested in PHP tutorials.