一、创建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中配置自动加载资源。
如对本文有疑问, 点击进行留言回复!!
DM数据库:dm.ini参数(五)预先装载表、客户端缓存、REDO 日志、事务相关参数
php+mysql获取7天、30天的统计数据,没有数值的补充0 By勤勤学长
第一章 第六小节Duilib的WindowImplBase基类OnCreate函数中调用AttachDialog函数
网友评论