| 主機參考:VPS測評參考推薦/專注分享VPS服務器優惠信息!若您是商家可以在本站進行投稿,查看詳情!此外我們還提供軟文收錄、PayPal代付、廣告贊助等服務,查看詳情! |
| 我們發布的部分優惠活動文章可能存在時效性,購買時建議在本站搜索商家名稱可查看相關文章充分了解該商家!若非中文頁面可使用Edge瀏覽器同步翻譯!PayPal代付/收錄合作 |

dedecms dream tag關鍵詞如何調用相關文章?
DEDE官方的dede:likearticle使用文章中輸入的關鍵詞或自動分詞形成的關鍵詞來關聯文章,但有時自動生成的關鍵詞不準確,導致關聯不準確。在這里,我們自定義一個類庫文件來實現對相關文章的準確訪問。
推薦學習:夢想編織cms
可以單獨使用tag調用相關文章,也可以使用tag+keyword調用相關文章(默認tag優先于keyword,可以自行排序)。
在\include\taglib\下添加一個liketags.lib.php代碼,如下所示
& lt?phpif(!已定義(& amp#39;德德恩公司。#39;))退出(& amp#39;請求錯誤!& amp#39;);函數lib _ liketags(& amp;$ ctag & amp;$ ref obj){ global $ dsql;//屬性處理$ attlist = & quotrow|12,titlelen|30,infolen|250,col|1,tablewidth|100,mytypeid|0,byabs|0,imgwidth|1,imgheight|90,flag | & quot;FillAttsDefault($ ctag-& gt;屬性-& gt;Items,$ attlist);提取($ ctag-》;屬性-& gt;Items,EXTR _ SKIP);$ revalue = & amp#39;& amp#39;;if(empty($ tablewidth))$ tablewidth = 100;if(empty($ col))$ col = 1;$ col width = ceil(100/$ col);$tablewidth = $tablewidth。"% & quot;$colWidth = $colWidth。"% & quot;$ orwheres = & amp#39;& amp#39;;if($ flag!= & amp#39;& amp#39;){ $ flags = explode(& amp;#39;,& amp#39;,$ flag);for($ I = 0;isset($ flags【$ I】);$ i++)$或orwheres。= & quot和FIND _ IN _ SET(& amp;#39;{ $ flags【$ I】} & amp;#39;,arc . flag)& gt;0 & quot;} $ ids = array();$ tids = array();如果(!空($ ref obj-& gt;字段【& amp#39;標簽& amp#39;】)){ $ keyword = $ ref obj-& gt;字段【& amp#39;標簽& amp#39;];} else { $keyword =(!空($ ref obj-& gt;字段【& amp#39;關鍵詞& amp#39;]) ?$ ref obj-& gt;字段【& amp#39;關鍵詞& amp#39;】:& amp#39;& amp#39;);} $typeid =(!empty($ mytypeid)?$ my typeid:0);if(empty($ typeid)){ if(!空($ ref obj-& gt;type link-& gt;TypeInfos【& amp;#39;里德& amp#39;】)){ $ typeid = $ ref obj-& gt;type link-& gt;TypeInfos【& amp;#39;里德& amp#39;];} else { if(!空($ ref obj-& gt;字段【& amp#39;typeid & amp#39;】))$ typeid = $ ref obj-& gt;字段【& amp#39;typeid & amp#39;];} } if(!empty($ typeid)& amp;& amp!preg _ match(& amp;#39;#,# & amp#39;,$ typeid)){ $ typeid = GetSonIds($ typeid);} if(!空($ ref obj-& gt;字段【& amp#39;標簽& amp#39;】)& amp& amp$eregtype!= & amp#39;關鍵詞& amp#39;){ $ tags = explode(& amp;#39;,& amp#39;,add slashes($ ref obj-& gt;字段【& amp#39;標簽& amp#39;]));$ getsql = & quot標簽like & amp#39;"。加入(& quot& amp#39;或標簽如& amp#39;",$tags)。"& amp#39;";$ dsql-& gt;執行(& amp#39;我和。#39;,& quotselect * From ` dede _ tag index ` where $ getsql & quot;);while($ arow = $ dsql-& gt;GetArray(& amp;#39;我和。#39;)){ $ tids【】= $ arow【& amp;#39;id & amp#39;];} $ tid = join(& amp;#39;,& amp#39;,$ tids);if($ tid!= & amp#39;& amp#39;){ 061 $ dsql-& gt;執行("我& quot,& quot從“dede_taglist”中選擇aid,其中tid in($ tid)和arcrank & gt-1組按援助順序由援助desc & quot;);while($ arow = $ dsql-& gt;GetArray(& quot;我& quot)){ $ ids【】= $ arow【& amp;#39;援助與發展。#39;];$ arcid = $ ref obj-& gt;字段【& amp#39;援助與發展。#39;];} } } if($ ereg type = = & amp;#39;標簽& amp#39;& amp& ampcount($ ids)= = 0){ return;} else { if(count($ ids)& gt;0){ if(!empty($ typeid)){ $ typeid = & quot;($typeid)和arc.id & lt& gt$ arcid & quot;} $ idsStr = join(& amp;#39;,& amp#39;,$ ids);$ query = & quot選擇弧線。*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,TP . sitepath from ` dede _ archives ` arc left join ` dede _ arc type ` TP on arc . typeid = TP . id where arc . arc rank & gt;-1和arc . id in($ idsStr)$ typeid order by arc . id desc限制0,$ row & quot;} else { $ limit row = $ row-count($ ids);$ keyword = & amp#39;& amp#39;;如果(!空($ ref obj-& gt;字段【& amp#39;關鍵詞& amp#39;】)){ $ keywords = explode(& amp;#39;,& amp#39;,trim($ ref obj-& gt;字段【& amp#39;關鍵詞& amp#39;]));$ keyword = & amp#39;& amp#39;;$ n = 1;foreach($ keywords as $ k){ if($ n & gt;3)打破;if(trim($ k)= & amp;#39;& amp#39;)繼續;else $ k = add slashes($ k);$關鍵字。=($ keyword = = & amp;#39;& amp#39;?"CONCAT(arc . keywords,& amp#39;& amp#39;,arc . title)like & amp;#39;% $ k % & amp#39;":& quot或CONCAT(arc . keywords,& amp#39;& amp#39;,arc . title)like & amp;#39;% $ k % & amp#39;");$ n++;}}$arcid =(!空($ ref obj-& gt;字段【& amp#39;id & amp#39;]) ?$ ref obj-& gt;字段【& amp#39;援助與發展。#39;] : 0);if(empty($ arcid)| | $ by ABS = = 0){ $ order query = & quot;按arc . id desc & quot;;} else { $ orderquery = & quot按ABS(arc . id-& quot;。$arcid。")& quot;} if($ keyword!= & amp#39;& amp#39;){if(!empty($ typeid)){ $ typeid = & quot;($typeid)和arc.id & lt& gt$ arcid & quot;} $ query = & quot選擇弧線。*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,TP . sitepath from ` dede _ archives ` arc left join ` dede _ arc type ` TP on arc . typeid = TP . id where arc . arc rank & gt;-1和($ keyword)$ typeid $ order query limit 0,$ row & quot;}else{if(!empty($ typeid)){ $ typeid = & quot;arc . typeid in($ typeid)和arc.id & lt& gt$ arcid & quot;} $ query = & quot選擇弧線。*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,TP . sitepath from ` dede _ archives ` arc left join ` dede _ arc type ` TP on arc . typeid = TP . id where arc . arc rank & gt;-1和$typeid $orderquery limit 0,$ row & quot;} } } $ innertext = trim($ ctag-& gt;GetInnerText());if($ innertext = = & amp;#39;& amp#39;)$ innertext = GetSysTemplets(& amp;#39;part _ arclist.htm & amp#39;);$ dsql-& gt;SetQuery($ query);$ dsql-& gt;執行(& amp#39;鋁和鋁。#39;);$ artlist = & amp#39;& amp#39;;if($ col & gt;1){ $ art list = & quot;& lt表格寬度= & amp#39;$ tablewidth & amp#39;border = & amp#39;0 & amp#39;單元格間距= & amp#39;0 & amp#39;單元格填充= & amp#39;0 & amp#39;& gt\ r \ n & quot;} $ DTP 2 = new DedeTagParse();$ DTP 2-& gt;set namespace(& amp;#39;菲爾德& amp#39;,& amp#39;【& amp#39;,& amp#39;】& amp#39;);$ DTP 2-& gt;LoadString($ innertext);$ GLOBALS【& amp;#39;自動索引& amp#39;] = 0;$ line = $ rowfor($ I = 0;$ i & lt$ line$ i++){ if($ col & gt;1)$ art list。= & quot& lttr & gt\ r \ n & quot;for($ j = 0;$ j & lt$ col$ j++){ if($ col & gt;1)$ art list。= & quot& lttd寬度= & amp#39;$ colWidth & amp#39;& gt\ r \ n & quot;if($ row = $ dsql-& gt;GetArray(& quot;艾爾& quot)){ $ ids【】= $ row【& amp;#39;id & amp#39;];//處理一些特殊字段$ row【&;#39;信息與通訊。#39;】= $ row【& amp;#39;infos & amp#39;】= cn _ substr($ row【& amp;#39;描述&。#39;】,$ info len);$ row【& amp;#39;id & amp#39;】= $ row【& amp;#39;id & amp#39;];if($ row【& amp;#39;柯蘭克& amp#39;】& gt0 & amp& amp$ row【& amp;#39;arcrank & amp#39;】= = 0){ $ row【& amp;#39;arcrank & amp#39;】= $ row【& amp;#39;柯蘭克& amp#39;];} $ row【& amp;#39;文件名& amp#39;】= $ row【& amp;#39;arcurl & amp#39;】= GetFileUrl($ row【& amp;#39;id & amp#39;】,$ row【& amp;#39;typeid & amp#39;】,$ row【& amp;#39;發送日期& amp#39;】,$ row【& amp;#39;標題和標題。#39;】,$ row【& amp;#39;伊斯馬克& amp#39;】,$ row【& amp;#39;arcrank & amp#39;】,$ row【& amp;#39;名稱規則和名稱。#39;】,$ row【& amp;#39;typedir & amp#39;】,$ row【& amp;#39;貨幣與金融。#39;】,$ row【& amp;#39;文件名& amp#39;】,$ row【& amp;#39;摩爾斯特& amp#39;】,$ row【& amp;#39;網站鏈接& amp#39;】,$ row【& amp;#39;網站路徑與服務。#39;]);$ row【& amp;#39;typeurl & amp#39;】= gettype URL($ row【& amp;#39;typeid & amp#39;】,$ row【& amp;#39;typedir & amp#39;】,$ row【& amp;#39;isdefault & amp#39;】,$ row【& amp;#39;默認名稱和名稱。#39;】,$ row【& amp;#39;ispart & amp#39;】,$ row【& amp;#39;名稱規則和名稱。#39;】,$ row【& amp;#39;摩爾斯特& amp#39;】,$ row【& amp;#39;網站鏈接& amp#39;】,$ row【& amp;#39;網站路徑與服務。#39;]);if($ row【& amp;#39;litpic & amp#39;】= = = & amp;#39;-& amp;#39;| | $ row【& amp;#39;litpic & amp#39;】= = = & amp;#39;& amp#39;){ $ row【& amp;#39;litpic & amp#39;】= $ GLOBALS【& amp;#39;cfg _ cmspath & amp#39;].& amp#39;/images/default pic . gif & amp;#39;;} if(!preg _ match(quot;#^http:\/\/#i";,$ row【& amp;#39;litpic & amp#39;】)& amp& amp$ GLOBALS【& amp;#39;cfg _ multi _ site & amp#39;】= = = & amp;#39;Y & amp#39;){ $ row【& amp;#39;litpic & amp#39;】= $ GLOBALS【& amp;#39;cfg _ mainsite & amp#39;].$ row【& amp;#39;litpic & amp#39;];} $ row【& amp;#39;picname & amp#39;】= $ row【& amp;#39;litpic & amp#39;];$ row【& amp;#39;stime & amp#39;】= GetDateMK($ row【& amp;#39;出版日期& amp#39;]);$ row【& amp;#39;typelink & amp#39;】= & quot& lta href = & amp#39;"。$ row【& amp;#39;typeurl & amp#39;]."& amp#39;& gt"。$ row【& amp;#39;鍵入名稱和名稱。#39;]."& lt/a & gt;";$ row【& amp;#39;形象與設計。#39;】= & quot& ltimg src=&。#39;"。$ row【& amp;#39;picname & amp#39;]."& amp#39;border = & amp#39;& amp#39;寬度= & amp#39;$ imgwidth & amp#39;高度= & amp#39;$ imgheight & amp#39;alt = & amp#39;"。preg _ replace(quot;#【& amp;#39;& gt& lt】# & quot,& quot",$ row【& amp;#39;標題和標題。#39;])."& amp#39;& gt";$ row【& amp;#39;imglink & amp#39;】= & quot& lta href = & amp#39;"。$ row【& amp;#39;文件名& amp#39;]."& amp#39;& gt"。$ row【& amp;#39;形象與設計。#39;]."& lt/a & gt;";$ row【& amp;#39;全稱& amp#39;】= $ row【& amp;#39;標題和標題。#39;];$ row【& amp;#39;標題和標題。#39;】= cn _ substr($ row【& amp;#39;標題和標題。#39;】,$ title len);if($ row【& amp;#39;顏色和顏色。#39;]!= & amp#39;& amp#39;)$ row【& amp;#39;標題和標題。#39;】= & quot& ltfont color = & amp#39;"。$ row【& amp;#39;顏色和顏色。#39;]."& amp#39;& gt"。$ row【& amp;#39;標題和標題。#39;]."& lt/font & gt;";if(preg _ match(& amp;#39;# b # & amp#39;,$ row【& amp;#39;旗幟& amp#39;】))$ row【& amp;#39;標題和標題。#39;】= & quot& ltstrong & gt"。$ row【& amp;#39;標題和標題。#39;]."& lt/strong & gt;";$ row【& amp;#39;textlink & amp#39;】= & quot& lta href = & amp#39;"。$ row【& amp;#39;文件名& amp#39;]."& amp#39;& gt"。$ row【& amp;#39;標題和標題。#39;]."& lt/a & gt;";$ row【& amp;#39;plusurl & amp#39;】= $ row【& amp;#39;phpurl & amp#39;】= $ GLOBALS【& amp;#39;cfg _ phpurl & amp#39;];$ row【& amp;#39;memberurl & amp#39;】= $ GLOBALS【& amp;#39;cfg _ memberurl & amp#39;];$ row【& amp;#39;坦普爾圖爾公司。#39;】= $ GLOBALS【& amp;#39;cfg _ templeturl & amp#39;];if(is _ array($ DTP 2-& gt;CTags){ foreach($ DTP 2-& gt;CTags as $ k = & gt$ ctag){ if($ ctag-& gt;GetName()= = = & amp;#39;數組和數組。#39;){ $ DTP 2-& gt;assign($ k,$ row);} else { if(isset (row【$ ctag-& gt;GetName()】))$ DTP 2-& gt;分配($k,$ row【$ ctag-& gt;GetName()】);else $ DTP 2-& gt;分配(k & amp;#39;& amp#39;);} } $ GLOBALS【& amp;#39;自動索引& amp#39;]++;} $artlist。= $ DTP 2-& gt;GetResult()。"\ r \ n & quot;} //if hasRow else { $artlist。= & amp#39;& amp#39;;} if($ col & gt;1)$ art list。= & quot& lt/TD & gt;\ r \ n & quot;}//循環Col if($ Col & gt;1)$ I+= $ col-1;if($ col & gt;1)$ art list。= & quot& lt/tr & gt;\ r \ n & quot;}//循環線if($ col & gt;1)$ art list。= & quot& lt/table & gt;\ r \ n & quot;$ dsql-& gt;free result(& quot;艾爾& quot);return $ artlist}前臺模板調用
{ dede:like tags row = & amp;#39;3 & amp#39;mytypeid = & amp#39;6 & amp#39;eregtype = & amp#39;所有|標簽|關鍵字& amp#39;titlelen = & amp#39;250 & amp#39;infolen = & amp#39;250 & amp#39;} & lt李& gt& lta href = & quot【字段:arcurl/】& quot;title = & quot【field:title/】& quot;target = & quot_blank"& gt& ltdiv class = & quot列表-img & quot;& gt& ltimg src = & quot【field:litpic/】& quot;alt = & quot【field:title/】& quot;/& gt;& lt/div & gt;& ltdiv class = & quot列表信息& quot& gt& ltp class = & quot標題& quot& gt【field:title/】& lt;/p & gt;& ltp class = & quotmeta & quot& gt【field:description/】& lt;/p & gt;& lt/div & gt;& lt/a & gt;& lt/李& gt{/dede:liketags}
這幾篇文章你可能也喜歡:
- 清理緩存后,Dedecms尚未刷新頁面。如何解決?
- 如何將新用戶添加到DEDECMS如何設置用戶權限
- 為DEDECMS用戶分配權利的最佳實踐政策?
- DEDECM如何集成第三方統計工具(例如Youmeng)?
- DEWECMS移動適應的常見問題和解決方案?
本文由主機參考刊發,轉載請注明:Dedecms Dreaming標簽關鍵詞如何調用相關文章 http://m.k2270.com/115550.html
主機參考

















評論前必須登錄!
注冊