destoon 内容页批量调用所有自定义字段的方法
destoon 内容页批量调用所有自定义字段的方法一个一个的在模板里调,是不是太麻烦了,下面的方法就是批量循环出当前频道所有不为空的自定义字段内容。api/extend.func.php 中添加以下函数function getfileds($tb){
global $db;
$result = $db->query("select name,title from {$db->pre}fields where tb='$tb' order by listorder asc");
$tags = array();
while($r = $db->fetch_array($result)){
$tags[] = $r;
}
return $tags;
}在内容页中使用
{php $atts = getfileds('mall');}
{loop $atts $i $v}
{if $v}<li>{$v}:{$v}</li>{/if}
{/loop}注意:其中 getfileds('mall')中的mall 是当前频道的表名,商城是 mall供应 sell_5 求购 buy_6更我表名请到后台数据库备份那里查看,这里不需要传表前缀。
页:
[1]