将Smarty与Codeigniter结合使用 [英] using smarty with codeigniter

查看:54
本文介绍了将Smarty与Codeigniter结合使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想同时使用codeigniter和smarty.即我想使用HTML文件,而不是像smarty那样使用codeigniter的.tpl.php文件.这是可能的还是我该怎么做.我进行了很多搜索,找到了一些示例,但没有我要求的一些作品.

I wants to use codeigniter and smarty together.i.e. I wants to use html files instead of .tpl.php files of codeigniter as of smarty. Is this possible or how can I do this.I have searched a lot and find some examples but none of some works as required by me.

推荐答案

您应该创建一个库 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;
}
}

及其用途:

$this->load->library("Smarty_tpl");
$this->smarty_tpl->display("...");

这篇关于将Smarty与Codeigniter结合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆