最近新客小編再查織夢標簽的問題,碰巧搜到下面這篇內容了,感覺有用,就先留下,
織夢/dedecms TAG標簽按欄目顯示(只顯示當前欄目標簽)
。弄了半天終于知道如何讓DEDE的TAG標簽按欄目顯示,只顯示當前欄目的所有標簽:D
一、打開include/taglib/目錄下的 tag.lib.php 文件
找到下面這段代碼,并在中間插入標注部分代碼
<ol class="dp-xml"><li class="alt"><span><span>if($</span><span class="attribute">getall</span><span>==0 && isset($refObj-</span><span class="tag">></span><span>Fields['tags']) && !empty($refObj-</span><span class="tag">></span><span>Fields['aid'])) </span></span></li><li><span>{ </span></li><li class="alt"><span> $dsql-<span class="tag">></span><span>SetQuery("Select tid From `ddmx_taglist` where </span><span class="attribute">aid</span><span> = '{$refObj-</span><span class="tag">></span><span>Fields['aid</span><span class="attribute-value">']}'</span><span> "); </span></span></li><li><span> $dsql-<span class="tag">></span><span>Execute(); </span></span></li><li class="alt"><span> $<span class="attribute">ids</span><span> = </span><span class="attribute-value">''</span><span>; </span></span></li><li><span> while($<span class="attribute">row</span><span> = $dsql-</span><span class="tag">></span><span>GetArray()) </span></span></li><li class="alt"><span> { </span></li><li><span> $ids <span class="attribute">.</span><span>= ( $</span><span class="attribute">ids</span><span>=='' ? $row['tid'] : ','.$row['tid'] ); </span></span></li><li class="alt"><span> } </span></li><li><span> if($ids != '') </span></li><li class="alt"><span> { </span></li><li><span> $<span class="attribute">addsql</span><span> = </span><span class="attribute-value">" where id in($ids) "</span><span>; </span></span></li><li class="alt"><span> } </span></li><li><span> if($<span class="attribute">addsql</span><span>=='') return ''; </span></span></li><li class="alt"><span>} </span></li><li><span> </span></li><li class="alt"><span style="background-color: rgb(255, 255, 153); "><strong>else if($<span class="attribute">getall</span>==2) </strong></span></li><li><span style="background-color: rgb(255, 255, 153); "><strong>{ </strong></span></li><li class="alt"><span style="background-color: rgb(255, 255, 153); "><strong>$<span class="attribute">addsql</span> = <span class="attribute-value">" where typeid='{$refObj->Fields['typeid']}' "</span>; </strong></span></li><li><span style="background-color: rgb(255, 255, 153); "><strong>}</strong></span><strong><span> </span></strong></li><li class="alt"><span>else </span></li><li><span>{ </span></li><li class="alt"><span> if(!empty(0id)) </span></li><li><span> { </span></li><li class="alt"><span> $<span class="attribute">addsql</span><span> = </span><span class="attribute-value">" where typeid='0id' "</span><span>; </span></span></li><li><span> } </span></li></ol>
二、修改你的模板
模板調用如下:
<ol class="dp-xml"><li class="alt"><span><span>{dede:tag </span><span class="attribute">sort</span><span>=</span><span class="attribute-value">'hot'</span><span> </span><span class="attribute">getall</span><span>=</span><span class="attribute-value">'2'</span><span>} </span></span></li><li><span><span class="tag"><</span><span class="tag-name">a</span><span> </span><span class="attribute">href</span><span>=</span><span class="attribute-value">'[field:link/]'</span><span class="tag">></span><span>[field:tag /]</span><span class="tag"></</span><span class="tag-name">a</span><span class="tag">></span><span> </span></span></li><li class="alt"><span>{/dede:tag} </span></li></ol>
搞定