织梦DedeCMS系统列表页调用TAG标签并带上链接的实现方法
网络整理 - 07-21
在include/common.func.php里面增加函数:
//列表页标签调用 function listtag($aid) { global $dsql; $tags=""; $sql = "Select i.tag From zmb_taglist t left join zmb_tagindex i on i.id=t.tid where t.aid='$aid'"; $dsql->SetQuery($sql); $dsql->Execute(); while($row = $dsql->GetArray()){ $arr[]=$row[tag]; } foreach($arr as $key=>$value){ $tg = $value; $tags .= "<a href='/tags.php?/".urlencode($tg)."/'>".$tg."</a> "; } return $tags; }使用方法
{dede:list pagesize='15' titlelen='70'} <div> <h2><a href="[field:arcurl/]" target="_blank">[field:title function='html2text(@me)' /]</a></h2> [field:description/]... <a href="[field:arcurl/]" target="_blank">查看详细>></a> <span><em>[field:click/]围观</em><em>标签:[field:id function="listtag(@me)"/] </em></span> </p> </div> {/dede:list}