VPS参考测评推荐
专注分享VPS主机优惠信息
衡天云优惠活动
华纳云优惠活动
荫云优惠活动

Dedecms Dreaming标签关键词如何调用相关文章

主机参考:VPS测评参考推荐/专注分享VPS服务器优惠信息!若您是商家可以在本站进行投稿,查看详情!此外我们还提供软文收录、PayPal代付、广告赞助等服务,查看详情!
我们发布的部分优惠活动文章可能存在时效性,购买时建议在本站搜索商家名称可查看相关文章充分了解该商家!若非中文页面可使用Edge浏览器同步翻译!PayPal代付/收录合作

Dedecms Dreaming标签关键词如何调用相关文章

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,& 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;描述&amp。#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=&amp。#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&quot& 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 Dreaming标签关键词如何调用相关文章 https://zhujicankao.com/115550.html

【腾讯云】领8888元采购礼包,抢爆款云服务器 每月 9元起,个人开发者加享折上折!
打赏
转载请注明原文链接:主机参考 » Dedecms Dreaming标签关键词如何调用相关文章
主机参考仅做资料收集,不对商家任何信息及交易做信用担保,购买前请注意风险,有交易纠纷请自行解决!请查阅:特别声明

评论 抢沙发

评论前必须登录!