1. 程式人生 > >destoon6.0批量調用所有自定義字段

destoon6.0批量調用所有自定義字段

order by 後臺數據庫 b- order 前綴 from func 自己 ext

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[name]}<li>{$v[title]}:{$$v[name]}</li>{/if}
{/loop}

註意:其中 getfileds(‘mall‘) 中的mall 是當前頻道的表名,商城是 mall 供應 sell_5 求購 buy_6 更我表名請到後臺數據庫備份那裏查看,這裏不需要傳表前綴。

順便分享下,自己這段時間做的行業平臺 圓柱模板 http://zhimo.yuanzhumuban.cc/ -支模網

destoon6.0批量調用所有自定義字段