我的字符串用addslashes解释后,用
$smarty->register_modifier("sslash","stripslashes");
{$blog_id.blog_myblog|truncate:1000|sslash}
进行还原解释。
smarty中的register_modifie函数
2008-02-16 11:46
注册修饰器
void register_modifier (string name, mixed impl)
Use this to dynamically register modifier plugin. Pass in the template modifier name, followed by the PHP function that it implements it.
动态注册一个修饰器插件,需要制定模板修饰器的名称,和实现具体功能的函数。
The php-function callback impl can be either (a) a string containing the function name or (b) an array of the form array(&$object, $method) with &$object being a reference to an object and $method being a string containing the mehod-name or (c) an array of the form array(&$class, $method) with $class being a classname and $method being a class method of that class.
执行函数的格式可以是一个包含函数名称的字符串;也可以是一个array(&$object, $method)数组形式,其中&$object是一个对象的引用,而$method是它的一个方法;还可以是一个array(&$ class, $method)数组形式,其中$class是一个类的名称,$method是类中的一个方法。
Example 13-23. register_modifier 例子 13-23. 注册修饰器
// let's map PHP's stripslashes function to a Smarty modifier. // 把PHP的stripslashes函数影像为Smarty模板的修饰器
$smarty->register_modifier("sslash","stripslashes");
// now you can use {$var|sslash} to strip slashes from variables // 现在可以在模板中使用{$var|sslash}的格式来去除变量中的特殊符号了
|
|
|
分享到:
相关推荐
Smarty 模板引擎教程,内容主要有基本语法、变量、组合修改器、内建函数、自定义函数、配置文件、控制台调试、缓存、插件扩展、使用技巧和经验等,比较详细的一个中文手册
smarty_man_zh.rar 手册帮助文件
一个仿www.fanfou.com的PHP网站代码,从架构实现动态换模板,动态换语言,用到session写入数据库,smarty模板等技术
教程名称:全面掌握smarty视频教程_韩顺平(24讲) ... 【】全面掌握smarty视频教程-第1-4讲 ... 【】全面掌握smarty视频教程-第13-16讲 ...资源太大,传百度网盘了,链接在附件中,有需要的同学自取。
smarty_函数文档[定义].pdf
SMARTY_DIR [Smarty目录] 12. Variables [变量] $template_dir [模板目录变量] $compile_dir [编译目录变量] $config_dir [配置目录变量] $plugins_dir [插件目录变量] $debugging [调试变量] $debug_tpl ...
Smarty中文手册 jquery_api Zend_Framework_zh jQuery_CHM_1.4.4 中文版四大集合!
SMARTY_DIR [Smarty目录] 12. Variables [变量] $template_dir [模板目录变量] $compile_dir [编译目录变量] $config_dir [配置目录变量] $plugins_dir [插件目录变量] $debugging [调试变量] $debug_tpl ...
以前从网上找到的一个smarty模板的中文截取函数cn_truncate,原来的实现方法有几个bug,我对它基本上重写了一遍。不过实现的功能和思想还是借鉴原来函数的。最重要的是解决了中英文混合时候的截取计算长度的问题。...
//如果有中文则减去中文的个数 function smarty_modifier_truncate($string, $sublen = 80, $etc = '...', $break_words = false, $middle = false)
Smarty PHP Template Programming and Applications 随书代码
php_pear_smarty_manual打包手册 零资源分方便大家下载
smarty+AJAX实例
主要介绍了smarty自定义函数htmlcheckboxes用法,实例分析了smarty模板与函数的使用技巧,需要的朋友可以参考下
Smarty_学习手册最全面的Smarty_学习手册
1、Smarty缓存的配置 $smarty->cache_dir = "/caches/"; //缓存目录 $smarty->caching = true; //开启缓存,为flase的时侯缓存无效 $smarty->cache_lifetime = 60; //缓存时间2、Smarty缓存的使用和清除 $...
TXTCMS 是一款基于php+smarty+txt数据库开发的网站内容管理系统,遵循MVC设计模式。本程序不依赖任何数据库,采用txt文本数据库存储方式存储数据,实现跨平台。不用数据库也能实现CURD,支持分表,史上最好的无...
主要介绍了smarty模板引擎中自定义函数的方法,实例分析了自定义函数的定义、注册及调用技巧,需要的朋友可以参考下
smarty中文手册smarty中文手册smarty中文手册smarty中文手册smarty中文手册smarty中文手册smarty中文手
SMARTY中文模板手册