1、创建块函数
function smarty_block_b_info($arr, $content, $repeat) {if ($repeat) { $ci = &get_instance(); $res = $ci->db->get('val', $arr['limit'])->result_array();
$str = ''; $tmp = $content;
foreach ($res as $k => $v) { $rs = str_replace('field.id', $v['id'], $tmp); $str .= str_replace('field.val', $v['val'], $rs); }
return $str; } }
2、前端视图调用块函数
<body> <ul> {b_info limit=10} <li> <div>field.id</div><div>field.val</div> </li> {/b_info} </ul> </body>
翻译
搜索
复制
标签:info,ci3,arr,val,smarty,dedecms,field,str From: https://www.cnblogs.com/haokan/p/18225393