DEDE的相关文章完全不相关,有朋友在DEDE官方放出根据TAG显示相关文章,也是很不错,可惜我在根据那边文章改DEDE代码后老是不行,可能是能力有限,当然也有可能是代码有问题
现在终于出了解决办法:
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);
//关键字分词技术
$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);
$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>";
上一页12 下一页 阅读全文