使用smarty与codeigniter

Ram*_*Ram 1 php codeigniter smarty

我想一起使用codeigniter和smarty.我想使用html文件而不是smartign的codeigniter的.tpl.php文件.这是可能的,或者我怎么能这样做.我已经搜索了很多并找到了一些例子,但是没有一些按照我的要求工作.

uzs*_*olt 5

你应该创建一个库Smarty_tpl.php:

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
//smarty class
require BASEPATH . "../../smarty/libs/Smarty.class.php";

class Smarty_tpl extends Smarty {

function __construct(){
    parent::__construct();

    $smarty_dir = BASEPATH . "../../smarty/libs/";

    $this->setTemplateDir(APPPATH."views/templates");
    $this->setCompileDir(APPPATH."views/templates_c");
    $this->setCacheDir(APPPATH."views/cache");
    $this->setConfigDir(APPPATH."views/config");
    $this->setPluginsDir(array("$smarty_dir/plugins","$smarty_dir/sysplugins/"));
    $this->compile_check=   true;
    $this->force_compile=   true;
    $this->caching=         true;
    $this->cache_lifetime=  86400;
}
}
Run Code Online (Sandbox Code Playgroud)

它的使用:

$this->load->library("Smarty_tpl");
$this->smarty_tpl->display("...");
Run Code Online (Sandbox Code Playgroud)