smarty中自定义函数
来源:互联网 发布:网络交流平台的优势 编辑:程序博客网 时间:2024/05/16 08:35
语法格式类似于html标记的写法
<{……}>
一、了解smarty自定义函数
例如:
1) smarty自定义函数assign
作用:用于在模板被执行时为模板变量赋值.
函数名称:assign
参数:var: 声明变量名称 字符串
Value: 给该变量赋值 字符串
<{assign var=”title” value=”this is title”}>
$tpl->assign(“title”,”this is title”);
该 属性无顺序要求
<{config_load file=”*.conf” section=”one”}>
2) smarty方法assign
二、实现自定义函数
1)例如:
a.html
<{title num=”10” content=”aaaa” size=”10” color=”red” }>
b.php
第一步:自定义函数
function fun1(){}
第二步:注册自定义函数
$tpl->register_function(“模板文件中的函数名”,”php中的函数名”)
Plugins/function_自定义函数名_*
2) 注册块
$tpl->register_block(“模板文件中的块名”,”php中的函数名”)
<hr />
<br />
<a> </a>块
a.html
<{h num=10 content=”aaa”}>
<{/h}>
3) 在plugins目录下新建文件
新建函数文件 world
例如:function.assign_debug_info.php
步骤
第一步:plugins下新建文件function.world.php
第二步:打开文件
Function smarty_function_world($args,&$smarty){..}
新建块文件hello
block.hello.php
function smarty_block_hello(){}
第一步:plugins下新建块文件block.hello.php
第二步:打开文件
Function smarty_block_hello($args,$content,&$smarty){..}
- smarty中自定义函数
- 在smarty中自定义函数
- 【smarty】smarty自定义函数
- 【smarty】smarty中自定义函数和自定义块
- Smarty中自定义函数与调用方法
- 了解smarty自定义函数
- smarty自定义函数
- smarty自定义函数总结
- smarty自定义函数
- smarty自定义函数
- smarty自定义函数
- smarty自定义函数1
- smarty自定义函数
- smarty自定义函数
- smarty的自定义函数
- smarty自定义函数
- smarty 自定义函数
- SMARTY自定义函数总结
- C语言:用快速排序算法对一个数组进行排序
- Ubuntu系统上轻松截图的几种方法介绍
- Pogoplug Cloud 提供你 5GB 的免费云端空间
- java 删除指定路径下的文件
- 实现Ajax友好的搜索引擎爬虫-jrex,gecko
- smarty中自定义函数
- goldengate 故障及解决方法汇总
- Exchange 2003的安装
- Win7下VS2008编译CGAL3.9
- 中国人是“营养盲”???
- C语言creat 文件的默认权限
- 常用英语翻译与技巧总结
- 获取Linux系统临时目录文件(类似Windows下的GetTempPath)
- 初步了解jackson,简单的使用jackson的annotation