dedecms相关文章以关键字怎么修改?
DEDE的相关文章完全不相关,有朋友在DEDE官方放出根据TAG显示相关文章,也是很不错,可惜我在根据那边文章改DEDE代码后老是不行,可能是能力有限,当然也有可能是代码有问题
推荐学习:织梦cms
现在终于出了解决办法:
1 在 inc_functions.php 最后?>前 加上
代码如下:
//查询指定栏目里包含相应关键字的文章,并列出 //参数说明:$showImg 是否显示缩略图,0表示不显示,1表示显示 // $titleLen 标题长度,0表示无限 // $rowCount 输出行数,0表示无限 // $typeid 栏目ID,0表示所有栏目 // $keyWord 关键字,字符串 function ShowKeyWordArc($showImg,$titleLen,$rowCount,$typeid,$keyWord){ $dsql = new DedeSql(false); $sql = TypeGetSunID($typeid,$dsql); </p> <p>//关键字分词技术 $ks = explode(" ",$keyWord); foreach($ks as $k){ $k = trim($k); if ($k!="") { $kwsqlarr[] = " (xkzzz_archives.title like '%$k%')"; //$kwsqlarr[] = " (xkzzz_archives.keywords like '%$k%') "; //如果需要相关到其它文章的关键字,解除此行注释 } } $where = implode(' OR ',$kwsqlarr); </p> <p>$sql="Select tp.namerule,tp.typedir,xkzzz_full_search.aid,xkzzz_full_search.url,xkzzz_archives.* From xkzzz_full_search left join xkzzz_archives on xkzzz_full_search.aid=xkzzz_archives.ID left join xkzzz_arctype tp on xkzzz_archives.typeid=tp.ID where {$sql} and ((xkzzz_archives.title like '%".$keyWord."%') or $where) order by xkzzz_full_search.aid desc"; $dsql->SetQuery($sql); $dsql->Execute(); $ss=""; $i=0; while($row=$dsql->GetObject()){ $url=GetFileUrl($row->ID,$row->typeid,$row->senddate,$row->title,$row->ismake,$row->arcrank,$row->namerule,$row->typedir,$row->money); if ($showImg==0){ $ss=$ss."<LI><a href='".$url."' target=_blank>"; if ($titleLen!=0) $ss=$ss.cn_substr($row->title,$titleLen); else $ss=$ss.$row->title; $ss=$ss."</A></LI>"; }else{ $ss=$ss."<LI><span class='sjdqimggl'><a href='".$url."' target=_blank>"; </p> <p>if ($row->litpic!="") $ss=$ss."@@##@@litpic."' alt='".$row->title."' />"; else $ss=$ss."@@##@@"; $ss=$ss."</a></span><span class='sjdqtxttl'><a href='".$url."' target=_blank>"; if ($titleLen!=0) $ss=$ss.cn_substr($row->title,$titleLen); else $ss=$ss.$row->title; $ss=$ss."</A></span></LI>"; } $i++; if (($rowCount!=0)&&($i>=$rowCount)) return $ss; } return $ss; }登录后复制
本文地址:http://ezhuoer.com