smarty 基本配置以及常见语句
2012-08-01 15:19
260 查看
使用smarty 将 libs 目录复制到项目目录。
基本配置
扩展配置
index.php
只需要导入 SmartySetup 并实例化一个对象即可完成配置
smarty的语句
基本配置
<?php iclude "./libs/Smarty.class.php"; $tpl = new Smarty(); // 模板文件目录 $tpl -> temlate_dir = 'templates/'; // 编译目录 $tpl -> compile_dir = 'templates_c/'; // 配置文件目录 $tpl -> config_dr = 'config/'; // 缓存目录 $tpl -> cache_dir = 'cache/'; // 开启缓存 $tpl -> caching = 1; // 设置缓存有效期 $tpl -> cache_lifetime = 60 * 60 * 24; $tpl -> left_delimiter = '<{'; $tpl -> right_delimiter = '}>'; ?>
扩展配置
<?php require 'libs/Smarty.class.php'; class SmartySetup extends Smarty { const SMARTY_ROOT = './tpls'; public function __construct() { parent :: __construct(); $this -> template_dir = self :: SMARTY_ROOT . '/templates/'; $this -> compile_dir = self :: SMARTY_ROOT . '/templates_c/'; $this -> config_dir = self :: SMARTY_ROOT . '/config/'; } } ?>
index.php
<?php require 'setup.php'; $tpl = new SmartySetup(); $tpl -> display('index.tpl'); ?>
只需要导入 SmartySetup 并实例化一个对象即可完成配置
smarty的语句
相关文章推荐
- Spring Boot基本配置和常见的运行时错误以及解决
- APK签名、混淆基本配置、打包以及常见问题
- 解决最小化安装Centos7后无法上网的问题,以及安装成功后的基本配置
- Xcode添加静态库以及编译选项配置常见问题
- Linux中vim的基本操作以及配置文件更改
- Select 语句执行顺序以及如何提高Oracle 基本查询效率
- mysql 常用函数以及常见查询语句
- linux上安装apache以及httpd.conf基本配置
- SSH原理和基本使用:ssh 安全配置 以及ssh key 认证登录
- 【转】Xcode添加静态库以及编译选项配置常见问题
- linux一些基本命令以及初级网络配置方法
- 关于james邮箱服务器配置、维护以及常见问题定位
- [转]SSH 原理和基本使用:ssh 安全配置 以及ssh key 认证登录
- linux上安装apache以及httpd.conf基本配置
- ubuntu 16.04学习笔记之安装Vim以及基本配置
- Xcode添加静态库以及编译选项配置常见问题
- Xcode添加静态库以及编译选项配置常见问题
- 关于IDEA的基本环境配置以及快速使用(git拉载程序,Jdk安装,tomcat部署,应用程序打包运行)
- Select 语句执行顺序以及如何提高Oracle 基本查询效率--原文链接http://www.cnblogs.com/likeju/p/5039128.html
- mybatis搭建核心结构,以及SQL基本配置