{"id":30291,"date":"2024-11-25T13:39:02","date_gmt":"2024-11-25T05:39:02","guid":{"rendered":"https:\/\/fwq.ai\/blog\/30291\/"},"modified":"2024-11-25T13:39:02","modified_gmt":"2024-11-25T05:39:02","slug":"dedecms%e6%96%87%e7%ab%a0%e5%88%97%e8%a1%a8%e9%a1%b5%e6%80%8e%e4%b9%88%e8%b0%83%e7%94%a8tag","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/30291\/","title":{"rendered":"DEDECMS\u6587\u7ae0\u5217\u8868\u9875\u600e\u4e48\u8c03\u7528tag"},"content":{"rendered":"<p style=\"text-align: center\"><strong><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/020\/5df2f75de5c1b403.jpg\" class=\"aligncenter\" title=\"DEDECMS\u6587\u7ae0\u5217\u8868\u9875\u600e\u4e48\u8c03\u7528tag\u63d2\u56fe\" alt=\"DEDECMS\u6587\u7ae0\u5217\u8868\u9875\u600e\u4e48\u8c03\u7528tag\u63d2\u56fe\" \/><\/strong><\/p>\n<p><strong>\u6587\u7ae0\u5217\u8868\u9875\u600e\u4e48\u8c03\u7528tag?<\/strong><\/p>\n<p>\u9996\u5148\u6253\u5f00DEDECMS\u6839\u76ee\u5f55include\/common.func.php&nbsp;<\/p>\n<p>\u63a8\u8350\u5b66\u4e60\uff1a<\/p>\n<p>\u5728\u6700\u5e95\u90e8 ?&gt; \u524d\u9762\u52a0\u5165\u4ee5\u4e0b\u4ee3\u7801:&nbsp;<\/p>\n<p>\u4ee3\u7801\u5982\u4e0b:<\/p>\n<pre>function&nbsp;listtag($aid)&nbsp;\n{&nbsp;\n$tsql&nbsp;=&nbsp;new&nbsp;DedeSql(false);&nbsp;\n$tags&nbsp;=&nbsp;'';&nbsp;\n$tsql-&amp;gt;SetQuery(\"Select&nbsp;i.tag&nbsp;From&nbsp;dede_taglist&nbsp;t&nbsp;left&nbsp;join&nbsp;dede_tagindex&nbsp;i&nbsp;on&nbsp;i.id=t.tid&nbsp;where&nbsp;t.aid='$aid'\");&nbsp;\n$tsql-&amp;gt;Execute('t');&nbsp;\nwhile($row&nbsp;=&nbsp;$tsql-&amp;gt;GetArray('t',MYSQL_ASSOC)){&nbsp;\n$tags&nbsp;.=&nbsp;\"&lt;a&gt;\".$row['tag'].\"&lt;\/a&gt;&nbsp;\";&nbsp;\n}&nbsp;\nreturn&nbsp;$tags;&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>2.\u7136\u540e\u5728\u6587\u7ae0\u9875\u53ef\u4ee5\u4f7f\u7528&nbsp;<\/p>\n<pre>{dede:field.id&nbsp;function=\"listtag(@me)\"\/}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6765\u8c03\u7528TAG\u6807\u7b7e,&nbsp;<\/p>\n<p>\u5728\u5217\u8868\u9875\u53ef\u4ee5\u4f7f\u7528&nbsp;<\/p>\n<pre>[field:id&nbsp;function=\"listtag(@me)\"\/]<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6765\u8c03\u7528TAG\u6807\u7b7e.<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fDEDECMS\u6587\u7ae0\u5217\u8868\u9875\u600e\u4e48\u8c03\u7528tag\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u5217\u8868\u9875\u600e\u4e48\u8c03\u7528tag? \u9996\u5148\u6253\u5f00DEDECMS\u6839\u76ee\u5f55include\/common.func.php&nbsp; \u63a8\u8350\u5b66\u4e60\uff1a \u5728\u6700\u5e95\u90e8 ?&gt; \u524d\u9762\u52a0\u5165\u4ee5\u4e0b\u4ee3\u7801:&nbsp; \u4ee3\u7801\u5982\u4e0b: function&nbsp;listtag($aid)&nbsp; {&nbsp; $tsql&nbsp;=&nbsp;new&nbsp;DedeSql(false);&nbsp; $tags&nbsp;=&nbsp;&#8221;;&nbsp; $tsql-&amp;gt;SetQuery(&#8220;Select&nbsp;i.tag&nbsp;From&nbsp;dede_taglist&nbsp;t&nbsp;left&nbsp;join&nbsp;dede_tagindex&nbsp;i&nbsp;on&nbsp;i.id=t.tid&nbsp;where&nbsp;t.aid=&#8217;$aid'&#8221;);&nbsp; $tsql-&amp;gt;Execute(&#8216;t&#8217;);&nbsp; while($row&nbsp;=&nbsp;$tsql-&amp;gt;GetArray(&#8216;t&#8217;,MYSQL_ASSOC)){&nbsp; $tags&nbsp;.=&nbsp;&#8220;&lt;a&gt;&#8221;.$row[&#8216;tag&#8217;].&#8221;&lt;\/a&gt;&nbsp;&#8220;;&nbsp; }&nbsp; return&nbsp;$tags;&nbsp; } \u767b\u5f55\u540e\u590d\u5236 2.\u7136\u540e\u5728\u6587\u7ae0\u9875\u53ef\u4ee5\u4f7f\u7528&nbsp; {dede:field.id&nbsp;function=&#8221;listtag(@me)&#8221;\/} \u767b\u5f55\u540e\u590d\u5236 \u6765\u8c03\u7528TAG\u6807\u7b7e,&nbsp; \u5728\u5217\u8868\u9875\u53ef\u4ee5\u4f7f\u7528&nbsp; [field:id&nbsp;function=&#8221;listtag(@me)&#8221;\/] \u767b\u5f55\u540e\u590d\u5236 \u6765\u8c03\u7528TAG\u6807\u7b7e. \u4ee5\u4e0a\u5c31\u662fDEDECMS\u6587\u7ae0\u5217\u8868\u9875\u600e\u4e48\u8c03\u7528tag\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-30291","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=30291"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30291\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=30291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=30291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=30291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}