NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
\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} ~~~