dedecms织梦tag keyword怎么调用相关文章

作者 : 青柠哥 本文共7233个字,预计阅读时间需要19分钟 发布时间: 2023-07-11 共114人阅读

dedecms织梦tag keyword怎么调用相关文章

dedecms梦想标签关键词如何调用相关文章?

DEDE官方的dede:likearticle利用文章中输入的关键词或自动分词形成的关键词来关联文章,但有时自动生成的关键词并不准确,导致关联不准确。这里我们自定义一个类库文件,实现对相关文章的精确访问。

推荐学习:梦想编织cms

可以单独使用tag调用相关文章,也可以使用tag+keyword调用相关文章(默认tag优先于keyword,可以自己排序)。

在\\include\\taglib\\下添加一个liketags.lib.php代码,如下所示

lt;?服务器端编程语言(Professional Hypertext Preprocessor的缩写)
如果(!已定义(# 39;DEDEINC # 39))退出(# 39;请求错误!#39;);
函数lib _ like tags(amp;$ctag,amp$refObj)
{
全球$ 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;cattribute -gt;Items,$ at tlist);
提取($ ctag -gt;cattribute -gt;Items,EXTR _ SKIP);
$重估= # 39;#39;;

if(empty($ table width))$ table width = 100;
if(empty($ col))$ col = 1;
$ col width = ceil(100/$ col);
$ table width = $ table width . quot;% quot;
$ colWidth = $ colWidth.quot% quot;
$ orwheres = # 39#39;;
如果($flag!= #39;#39;) {
$ flags = explode(# 39;,#39;,$ flag);
for($ I = 0;isset($ flags[$ I]);$ i++)$ or where。= quot和FIND _ IN _ SET(# 39;{ $ flags[$ I]} # 39;,arc . flag)gt;0 quot;
}

$ ids = array();
$ tids = array();

如果(!empty($ ref obj -gt;字段[# 39;标签# 39;])) {
$ keyword = $ ref obj -gt;字段[# 39;标签# 39;];
}
否则{
$keyword =(!empty($ ref obj -gt;字段[# 39;关键词# 39;]) ?$ ref obj -gt;字段[# 39;关键词# 39;] : #39;#39;);
}

$typeid =(!空($mytypeid)?$ my typeid:0);
if(empty($typeid))
{
如果(!empty($ ref obj -gt;Typelink-gt。TypeInfos[# 39;里德# 39;])) {
$ typeid = $ ref obj -gt;Typelink-gt。TypeInfos[# 39;里德# 39;];
}
否则{
如果(!empty($ ref obj -gt;字段[# 39;typeid # 39]))$ typeid = $ ref obj -gt;字段[# 39;typeid # 39];
}
}

如果(!empty($ typeid)amp;amp!preg _ match(# 39;#,##39;,$typeid) ) {
$ typeid = GetSonIds($ typeid);
}

如果(!empty($ ref obj -gt;字段[# 39;标签# 39;])amp;amp$eregtype!= #39;关键词# 39;)
{
$ tags = explode(# 39;,#39;,add slashes($ ref obj -gt;字段[# 39;标签# 39;]));
$ getsql = quot标签如# 39;quot。加入(quot#39;或者像# 39;quot,$tags)。quot#39;quot;
$ dsql -gt;执行(# 39;我# 39;,quotselect * From ` dede _ tag index ` where$get SQL quot;);
while($ arow = $ dsql -gt;get array(# 39;我# 39;))
{
$ tids[]= $ arow[# 39;id # 39];
}
$ tid = join(# 39;,#39;,$ tids);
如果($tid!=#39;#39;)
{
061
$ dsql -gt;执行(quotmequot,quot从“dede_taglist”中选择aid,其中tid in($tid)和arcrank gt-1按援助顺序分组,按援助描述排序。);
while($ arow = $ dsql -gt;GetArray(quot;mequot))
{
$ ids[]= $ arow[# 39;援助# 39;];
$ arcid = $ ref obj -gt;字段[# 39;援助# 39;];
}
}
}
if($ eregtype = = # 39;标签# 39;ampamp计数($ids) == 0)
{
返回;
}
其他
{
if(count($ ids)gt;0)
{
如果(!空($typeid))
{
$ typeid = quot以及($typeid)和arc.idlt中的arc.typeidgt;$ arcid quot;
}
$ idsStr = join(# 39;,#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
从` dede_archives` arc向左连接` dede _ arc type ` TP on arc . typeid = TP . id
其中arc.arcrankgt-1和arc . id in($ idsStr)$ typeid order by arc . id desc限制0,$ rowquot;
}
其他
{
$ limit row = $ row -count($ ids);
$ keyword = # 39#39;;
如果(!empty($ ref obj -gt;字段[# 39;关键词# 39;]))
{
$ keywords = explode(# 39;,#39;,trim($ ref obj -gt;字段[# 39;关键词# 39;]));
$ keyword = # 39#39;;
$ n = 1;
foreach($关键字为$k)
{
if($ n gt;3)破;

if(trim($ k)= = # 39;#39;)继续;
else $ k = add slashes($ k);

$keyword。=($ keyword = = # 39;#39;?quotCONCAT(arc.keywords,# 39;#39;,arc.title)像# 39;% $ k % # 39quot:quot或者CONCAT(arc.keywords,# 39;#39;,arc.title)像# 39;% $ k % # 39quot);
$ n++;
}
}
$arcid =(!empty($ ref obj -gt;字段[# 39;id # 39]) ?$ ref obj -gt;字段[# 39;援助# 39;] : 0);
if( empty($arcid) || $byabs==0)
{
$ orderquery = quot按arc.id desc排序quot;
}
其他
{
$ orderquery = quot按ABS(arc . id -quot;。$ arcid.quot)quot;
}
if($关键字!= #39;#39;)
{
如果(!空($typeid))
{
$ typeid = quot以及($typeid)和arc.idlt中的arc.typeidgt;$ 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
从` dede_archives` arc向左连接` dede _ arc type ` TP on arc . typeid = TP . id
其中arc.arcrankgt-1和($ keyword)$ typeid $ order query limit 0,$ rowquot;
}
其他
{
如果(!空($typeid))
{
$ typeid = quot(typeid)中的arc.typeid和arc.idltgt;$ 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
从` dede_archives` arc向左连接` dede _ arc type ` TP on arc . typeid = TP . id
其中arc.arcrankgt-1和$typeid $orderquery限制0,$ rowquot;
}
}
}

$ innertext = trim($ ctag -gt;GetInnerText());
if($ innertext = = # 39;#39;)$ innertext = GetSysTemplets(# 39;part _ arclist.htm # 39);
$ dsql -gt;SetQuery($ query);
$ dsql -gt;执行(# 39;铝# 39;);
$ artlist = # 39#39;;
if($ col gt;1){
$ artlist = quotlt;表格宽度= # 39;$ tablewidth # 39border = # 390#39;单元格间距= # 39;0#39;cellpadding = # 390#39;gt;\\ r \\ nquot;
}
$ DTP 2 = new DedeTagParse();
$ DTP 2-gt;set namespace(# 39;字段# 39;, #39;[#39;, #39;]#39;);
$ DTP 2-gt;LoadString($ innertext);
$ GLOBALS[# 39;自动索引# 39;] = 0;
$ line = $ row
for($ I = 0;$ i lt$ line$i++)
{
if($ colgt;1) $artlist。= quotlt;trgt\\ r \\ nquot;
for($ j = 0;$ j lt$ col$j++)
{
if($ colgt;1) $artlist。= quotlt;td宽度= # 39;$ colWidth # 39gt;\\ r \\ nquot;
if($ row = $ dsql -gt;GetArray(quot;alquot))
{
$ ids[]= $ row[# 39;id # 39];
//处理一些特殊字段
$ row[# 39;信息# 39;]= $ row[# 39;信息# 39;]= cn _ substr($ row[# 39;描述# 39;],$ info len);
$ row[# 39;id # 39]= $ row[# 39;id # 39];

if($row[# 39;柯兰克# 39;]gt;0安培;amp$ row[# 39;arcrank # 39]==0)
{
$ row[# 39;arcrank # 39]= $ row[# 39;柯兰克# 39;];
}

$ row[# 39;文件名# 39;]= $ row[# 39;arcurl # 39]= GetFileUrl($ row[# 39;id # 39],$ row[# 39;typeid # 39],$ row[# 39;发送日期# 39;],$ row[# 39;标题# 39;],$ row[# 39;ismake # 39],
$ row[# 39;arcrank # 39],$ row[# 39;命名规则# 39;],$ row[# 39;typedir # 39],$ row[# 39;金钱# 39;],$ row[# 39;文件名# 39;],$ row[# 39;更多网站# 39;],$ row[# 39;siteurl # 39],$ row[# 39;站点路径# 39;]);

$ row[# 39;typeurl # 39]= GetTypeUrl($ row[# 39;typeid # 39],$ row[# 39;typedir # 39],$ row[# 39;is默认# 39;],$ row[# 39;默认名称# 39;],$ row[# 39;ispart # 39],
$ row[# 39;命名规则# 39;],$ row[# 39;更多网站# 39;],$ row[# 39;siteurl # 39],$ row[# 39;站点路径# 39;]);

if($row[# 39;litpic # 39] == #39;-#39;| | $ row[# 39;litpic # 39] == #39;#39;)
{
$ row[# 39;litpic # 39]= $ GLOBALS[# 39;cfg _ cmspath # 39].#39;/images/default pic . gif # 39;;
}
如果(!preg _ match(quot;#^http:\\/\\/#iquot;,$ row[# 39;litpic # 39])amp;amp$ GLOBALS[# 39;cfg _ multi _ site # 39] == #39;Y # 39)
{
$ row[# 39;litpic # 39]= $ GLOBALS[# 39;cfg _ mainsite # 39].$ row[# 39;litpic # 39];
}
$ row[# 39;picname # 39]= $ row[# 39;litpic # 39];
$ row[# 39;stime # 39]= GetDateMK($row[# 39;发布日期# 39;]);
$ row[# 39;typelink # 39]= quot;lt;a href = # 39quot。$ row[# 39;typeurl # 39].quot#39;gt;quot。$ row[# 39;typename # 39].quotlt;/AGT;quot;
$ row[# 39;图片# 39;]= quot;lt;img src = # 39quot。$ row[# 39;picname # 39].quot#39;border = # 39#39;width = # 39$ imgwidth # 39height = # 39$ imgheight # 39alt = # 39quot。preg _ replace(quot;#[#39;gt;lt;]# quot;,quotquot,$ row[# 39;标题# 39;]).quot#39;gt;quot;
$ row[# 39;imglink # 39]= quot;lt;a href = # 39quot。$ row[# 39;文件名# 39;].quot#39;gt;quot。$ row[# 39;图片# 39;].quotlt;/AGT;quot;
$ row[# 39;完整标题# 39;]= $ row[# 39;标题# 39;];
$ row[# 39;标题# 39;]= cn _ substr($ row[# 39;标题# 39;],$ title len);
if($row[# 39;颜色# 39;]!=#39;#39;)$ row[# 39;标题# 39;]= quot;lt;font color = # 39quot。$ row[# 39;颜色# 39;].quot#39;gt;quot。$ row[# 39;标题# 39;].quotlt;/fontgt。quot;
if(preg _ match(# 39;# b # # 39,$ row[# 39;标志# 39;]))$ row[# 39;标题# 39;]= quot;lt;stronggt。quot。$ row[# 39;标题# 39;].quotlt;/stronggt。quot;
$ row[# 39;textlink # 39]= quot;lt;a href = # 39quot。$ row[# 39;文件名# 39;].quot#39;gt;quot。$ row[# 39;标题# 39;].quotlt;/AGT;quot;
$ row[# 39;plusurl # 39]= $ row[# 39;phpurl # 39]= $ GLOBALS[# 39;cfg _ phpurl # 39];
$ row[# 39;memberurl # 39]= $ GLOBALS[# 39;cfg _ memberurl # 39];
$ row[# 39;templeturl # 39]= $ GLOBALS[# 39;cfg _ templeturl # 39];

if(is _ array($ DTP 2-gt;CTags))
{
foreach($ DTP 2-gt;CTags as $k=gt。$ctag)
{
if($ CTA G-gt;GetName()= = # 39;数组# 39;) {
$ DTP 2-gt;赋值($k,$ row);
}
否则{
if(isset($ row[$ ctag -gt;GetName()]))$ DTP 2-gt;Assign($k,$ row[$ ctag -gt;GetName()]);
else $ DTP 2-gt;赋值($k,# 39;#39;);
}
}
$ GLOBALS[# 39;自动索引# 39;]++;
}

$artlist。= $ DTP 2-gt;GetResult()。quot\\ r \\ nquot;
}
//如果有行
其他
{
$artlist。= #39;#39;;
}
if($ colgt;1) $artlist。= quotlt;/tdgt。\\ r \\ nquot;
}
//循环列
if($ colgt;1)$ I+= $ col -1;
if($ colgt;1) $artlist。= quotlt;/trgt。\\ r \\ nquot;
}
//循环线
if($ colgt;1) $artlist。= quotlt;/tablegt。\\ r \\ nquot;
$ dsql -gt;免费结果(quotalquot);
返回$ artlist
}登录后复制

青柠资源网专注于CMS网站模板,主流语言整站网站源码下载,网站建设相关教程分享,好用的软件素材整合下载,提供一站式便捷自助服务。
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 如遇到加密压缩包,默认解压密码为"www.qnziyw.cn",如遇到无法解压的请联系管理员!


青柠资源网 » dedecms织梦tag keyword怎么调用相关文章

常见问题FAQ

免费下载或者VIP会员专享资源能否直接商用?
本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍
提示下载完但解压或打开不了?
最常见的情况是下载不完整: 可对比下载完压缩包的与网盘上的容量,若小于网盘提示的容量则是这个原因。这是浏览器下载的bug,建议用百度网盘软件或迅雷下载。 若排除这种情况,可在对应资源底部留言,或 联络我们。
找不到素材资源介绍文章里的示例图片?
对于会员专享、整站源码、程序插件、网站模板、网页模版等类型的素材,文章内用于介绍的图片通常并不包含在对应可供下载素材包内。这些相关商业图片需另外购买,且本站不负责(也没有办法)找到出处。 同样地一些字体文件也是这种情况,但部分素材会在素材包内有一份字体下载链接清单

发表回复