smarty扩展
来源:互联网 发布:小草淘宝客下载 编辑:程序博客网 时间:2024/06/12 11:16
为了避免重复地配置路径,可以在一个smarty文件里配置扩展类,和初始化你的smarty环境。
我们创建一个目录 “/php/includes/guestbook/” 建立一个文件”setup.php”
同样先设置好smarty路径。
/php/includes/guestbook/setup.php
// load Smarty library require('Smarty.class.php'); // The setup.php file is a good place to load // required application library files, and you // can do that right here. An example: // require('guestbook/guestbook.lib.php');是一个很好的加载应用程序的类库文件(就是扩展类) //例如你可以在index文件里包含它 class Smarty_GuestBook extends Smarty { function Smarty_GuestBook() { // Class Constructor. These automatically get set with each new instance. //类构造函数.创建实例的时候自动配置 $this->Smarty(); $this->template_dir = '/web/www.mydomain.com/smarty/guestbook/templates/'; $this->compile_dir = '/web/www.mydomain.com/smarty/guestbook/templates_c/'; $this->config_dir = '/web/www.mydomain.com/smarty/guestbook/configs/'; $this->cache_dir = '/web/www.mydomain.com/smarty/guestbook/cache/'; $this->caching = true; $this->assign('app_name','Guest Book'); } }
现在我们针对setup文件更改一下index文件
编辑/web/www.mydomain.com/docs/guestbook/index.php
require('guestbook/setup.php'); $smarty = new Smarty_GuestBook; $smarty->assign('name','Ned'); $smarty->display('index.tpl');
现在你看到创建一个使用smarty的实例有多么的简单.从Smarty_GuestBook开始,重新构建我们的应用程序吧^_^
- smarty扩展
- Smarty功能扩展
- smarty函数扩展
- smarty模板可扩展编程
- smarty 给include file 加扩展
- php中smarty扩展类问题
- Smarty
- Smarty
- smarty
- smarty
- Smarty
- smarty
- smarty
- smarty
- smarty
- smarty
- smarty、
- smarty
- imx515 uboot UBIFS移植及android UBIFS文件系统烧写
- Decorator 模式学习
- 用正则表达式自动下载网页中的图片
- Smaty的一些特点
- 超酷的 WebTTY
- smarty扩展
- asp实现下拉列表框间响应
- 版权符号©的4种输入方法
- java Excel下载时 需要配置输入流
- 电阻触摸屏电容触摸屏触摸屏
- Cisco 642-243 认证题库分享
- Spring Bean注册表
- About IP地址
- 局域网的几种工作模式