smarty 自定义函数

来源:互联网 发布:硬盘安装ubuntu 17.10 编辑:程序博客网 时间:2024/05/22 12:08

 注册函数
对模块进行的封装
就像 {@ html_radios@}
规则:
文件名:
function.标签名.php

eg:function.test.php
函数规则:
function smarty_function_标签名($param,&$smarty){

}

 

注册块
对页面中的数据内容,进行格式设置;
规则:
文件名:
block.标签名.php
函数名:
smarty_block_标签名($param,$content,&$smarty){}
eg:
font_color
block.font_color.php
function smarty_block_font_color($)

自定义修饰符:
给变量设置样式:
规则:
文件名:modifier.标签名.php
函数名: smarty_modifier_标签名($param,参数列表){

}
第一个参数是变量数据,从第二个参数开始时参数列表

eg:
插件文件名
modifier.add.php
插件内容
function
smarty_modifier_add($content){
return $content."作者:Damat";
}
plu.php
$smarty->assign("title","中国热门新闻");
plu.html
{@ $title|add@}


 

 在plugins目录下新建文件

新建函数文件 world

  例如:

function.assign_debug_info.php

function  smarty_function_***(){}

  步骤

第一步: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){..}

 

原创粉丝点击