關(guān)鍵字描述:相關(guān) 辦法 解決 文章   " < row-> ss &rsquo
DEDE的相關(guān)文章完全不相關(guān),有朋友在DEDE官方放出根據(jù)TAG顯示相關(guān)文章,也是很不錯,可惜我在根據(jù)那邊文章改DEDE代碼后老是不行,可能是能力有限,當(dāng)然也有可能是代碼有問題
現(xiàn)在終于出了解決辦法:
1 在 inc_functions.php 最后?>前 加上
- //查詢指定欄目里包含相應(yīng)關(guān)鍵字的文章,并列出
//參數(shù)說明:$showImg 是否顯示縮略圖,0表示不顯示,1表示顯示
// $titleLen 標(biāo)題長度,0表示無限
// $rowCount 輸出行數(shù),0表示無限
// $typeid 欄目ID,0表示所有欄目
// $keyWord 關(guān)鍵字,字符串
function ShowKeyWordArc($showImg,$titleLen,$rowCount,$typeid,$keyWord){
$dsql = new DedeSql(false);
$sql = TypeGetSunID($typeid,$dsql);
//關(guān)鍵字分詞技術(shù)
$ks = explode(" ",$keyWord);
foreach($ks as $k){
$k = trim($k);
if ($k!="") {
$kwsqlarr[] = " (xkzzz_archives.title like '%$k%') ";
//$kwsqlarr[] = " (xkzzz_archives.keywords like '%$k%') "; //如果需要相關(guān)到其它文章的關(guān)鍵字,解除此行注釋
}
}
$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 下一頁