企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
\plugins\自定义插件名称 block.test.php ~~~ <?php function smarty_block_test($params, $content){ $replace = $params['replace']; $maxnum = $params['maxnum']; if($replace == 'true'){ $content = str_replace(',', ',', $content); $content = str_replace('。', '.', $content); } $content = substr($content, 0, $maxnum); return $content; } ?> ~~~ 赋值 ~~~ $smarty->assign("str",'hello my name is cy,how are you?。'); $smarty->display('content.tpl'); ~~~ tpl中调用 ~~~ {test2 replace='true' maxnum=29} {$str} {/test2} ~~~