smarty自定义函数
来源:互联网 发布:大数据学术报告点评 编辑:程序博客网 时间:2024/06/05 16:39
一、了解smarty自定义函数
例如:
1) smarty自定义函数assign
作用:用于在模板被执行时为模板变量赋值.
函数名称:assign
参数:var: 声明变量名称 字符串
Value:给该变量赋值 字符串
<{assign var=”title” value=”this is title”}>
相当于: $tpl->assign(“title”,”this is title”);
<input type=”text” name=”input1”>
属性无顺序要求
<{config_load file=”*.conf” section=”one”}>
二、实现自定义函数
1)例如:
*.html
<{title num=”10” content=”aaaa” size=”10” color=”red” }>
b.php
第一步:自定义函数
function fun1(){}
第二步:注册自定义函数
$tpl->register_function(“模板文件中的函数名”,”php中的函数名”)
2) 注册块
$tpl->register_block(“模板文件中的块名”,”php中的函数名”)
*.html
<{h num=10 content=”aaa”}>
<{/h}>
3) 在plugins目录下新建文件
新建函数文件world
例如:
function.assign_debug_info.php
function smarty_function_***(){}
步骤
第一步:plugins下新建文件function.world.php
第二步:打开文件
Functionsmarty_function_world($args,&$smarty){..}
新建块文件hello
block.hello.php
function smarty_block_hello(){}
第一步:plugins下新建块文件block.hello.php
第二步:打开文件
Functionsmarty_block_hello($args,$content,&$smarty){..}
- 【smarty】smarty自定义函数
- 了解smarty自定义函数
- smarty自定义函数
- smarty自定义函数总结
- smarty自定义函数
- smarty自定义函数
- smarty自定义函数
- smarty自定义函数1
- smarty自定义函数
- smarty中自定义函数
- smarty自定义函数
- smarty的自定义函数
- smarty自定义函数
- smarty 自定义函数
- SMARTY自定义函数总结
- smarty自定义函数
- smarty自定义函数
- smarty自定义函数
- 使用response Redirect时候出现的错误
- 遥感基本概念
- 反射系列
- PHPCMS 2008 标签调用时间的格式说明
- 获取系统所有进程
- smarty自定义函数
- dl,dt,dd,ul,li,ol区别及应用
- 我是如何成长的(走向测试技术专家之路)
- 分页代码
- phpcms2008常用函数
- 黑马程序员---------关于socket编程
- 意外断电 。服务器出现 无法正常家在硬盘
- 开发人员非常有用的Java功能代码(1-10)
- 如何将样式表加入的网页