smarty变量调节器
用法 中间加 |
<{$test|capitalize}>首字母大写
<{$money|cat:"$"}> 连接字符串
<{$zifu|count_characters}>字符计数
<{$riqi|date_format:"%Y-%m-%d %H:%M:%S"}>格式化日期 <{$riqi|date_format:"%D %T"}>
<{$moren|default:"morenzhi"}>设置默认值
<{$suojin|indent}>缩进
<{$zhengze|regex_replace:"/\d/":"k"}>正则替换
<{$zhengze|replace:"o":"8"}>替换
<{$jiequ|truncate:8:"..."}> 截取 包括...空格占两个
自定义变量调节器
在plugins(插件)文件内写 文件名为modifier.yangshi.php
<?php
function smarty_modifier_yangshi($str,$color="red",$size="16") 传入的变量可以是多个
{
$str="<span style='color:{$color}; font-size:{$size}px'>$str</span>";
return $str;
}
JS
通过外层div的class取内层div 用children
$(this).children("div").css("display","block");