打开/include/extend.func.php文件
在最下面加入
<span style="font-size:14px;" deep="13">//自定义函数调用数据表function table($table, $field, $id){global $dsql;$primarys = array();$table = strpos($table, '#@_') === false?(strpos($table, 'dede_') === false?'dede_'.$table:str_replace('dede_','dede_',$table)):$table;$dsql -> Execute("me","SHOW COLUMNS FROM `$table`");while ($r = $dsql->GetArray()){if($r['Key'] == 'PRI') $primarys[] = $r['Field'];}if(!empty($primarys)){$primary = $primarys[0];$result = $dsql -> GetOne("SELECT `$field` FROM `$table` WHERE `$primary`= $id");}return isset($result[$field])?$result[$field]:$result[$field];}</span>
前端代码
<span style="font-size:14px;">{dede:field.id function='table("dede_addonarticle","body",@me)'/}</span>
详解
<span style="font-size:14px;">{dede:field.字段 function='table("要调用的数据表","要调用的字段",@me)'/} //内容页,首页调用代码[field:字段 function='table("要调用的表名","要调用的字段",@me)'/] //列表页频道页调用代码</span>