分类分类
更新时间:2015-06-29 11:25作者:fang
一、创建Smarty类库
1.将smarty的libs文件复制到libraries下(这里我重命名为smarty)
2.新建Cismarty.php文件。(符合文件规范,文件名的首字母和class名的首字母大写,但是控制器引用加载时,类名/文件名不需要大写)
Cismarty.php
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
require(APPPATH . 'libraries/smarty/Smarty.class.php');
//CI,文件系统全用相对路径相对index.php所在的路径,url全部用绝对路径。
//BASEPATH - The full server path to the "system" folder
//APPPATH - The full server path to the "application" folder
class Cismarty extends Smarty
{
public function __construct()
{
parent::__construct();
$this->caching = false;
$this->setTemplateDir(APPPATH . 'views/Smarty/templates'); //设定所有模板文件都需要放置的目录地址。
$this->setConfigDir(APPPATH . 'views/Smarty/configs'); //设定用于存放模板特殊配置文件的目录,
$this->setCacheDir(APPPATH . 'views/Smarty/cache'); //在启动缓存特性的情况下,这个属性所指定的目录中放置Smarty缓存的所有模板
$this->setPluginsDir(APPPATH . 'views/Smarty/plugins'); //插件目录
$this->setCompileDir(APPPATH . 'views/Smarty/templates_c'); //设定Smarty编译过的所有模板文件的存放目录地址
}
}
?>
在对应目录新建smarty的文件夹。templates,configs,cache,plugins,templates_c.
二、控制器文件
建立控制器文件paper.php(类名的首字母大写)(使用load加载libraries时默认执行构造器函数,使用url路由访问控制器时执行构造器函数和默认的index方法。)
paper.php:
<?php
class Paper extends CI_Controller
{
function __construct()
{
parent::__construct();
}
public function pri_body()
{
$this->load->library('cismarty');
$this->cismarty->assign("name", 1200);
$this->cismarty->display('dd.tpl');
}
}
?>
也可以在application/config/autoload.php中配置自动加载资源。
相关
纸片马里奥(Paperboat)角色扮演107.85 MBv1.0.32026-11-29
下载cyime输入法实用工具74.58 MBv1.15.1072026-11-29
下载武道仙宗官方版角色扮演456.19 Mv1.0.02026-11-29
下载mmrl模块app实用工具7.15 Mv342962026-11-29
下载零希沃特手机版角色扮演511.54 Mv1.4.22026-11-29
下载Bannerlator手游辅助574.84 MBv3.2.12026-11-29
下载巅峰激战(魔幻格斗游戏)动作射击797.1 MBv1.0.92026-11-29
下载我的火车防御策略游戏181.87 Mv1.1.52026-11-29
下载三国棋逢对手角色扮演1.7Gv1.2.5.0002.1125.11432026-11-29
下载图纸没问题手机版休闲益智78.41 Mv1.0.182026-11-29
下载蛊界永生角色扮演407.01 Mv0.4.162026-11-28
下载百炼仙途角色扮演528.9 Mv10002026-11-28
下载










