dedecms相關(guān)文檔不相關(guān)怎么辦?
DEDE的相關(guān)文章完全不相關(guān),有朋友在DEDE官方放出根據(jù)TAG顯示相關(guān)文章,也是很不錯(cuò),可惜我在根據(jù)那邊文章改DEDE代碼后老是不行,可能是能力有限,當(dāng)然也有可能是代碼有問題
推薦學(xué)習(xí):織夢cms
現(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[]?=?"?(dede_archives.title?like?'%$k%')?"; //$kwsqlarr[]?=?"?(dede_archives.keywords?like?'%$k%')?";?//如果需要相關(guān)到其它文章的關(guān)鍵字,解除此行注釋 } } $where?=?implode('?OR?',$kwsqlarr); $sql="Select?tp.namerule,tp.typedir,dede_full_search.aid,dede_full_search.url,dede_archives.*?From?dede_full_search?left?join?dede_archives?on?dede_full_search.aid=dede_archives.ID?left?join?dede_arctype?tp?on?dede_archives.typeid=tp.ID?where?{$sql}?and?((dede_archives.title?like?'%".$keyWord."%')?or?$where)?order?by?dede_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."
“; }else{ $ss=$ss.”
“; } $i?; if?(($rowCount!=0)&&($i>=$rowCount))?return?$ss; } return?$ss; }
2 放在文章模板頁內(nèi)
{dede:field?name=’keywords’?function=’ShowKeyWordArc(0,32,10,0,”@me”)’/}
就表示是取所有欄目內(nèi)的相關(guān)文章(與當(dāng)前文章的關(guān)鍵字相關(guān)),標(biāo)題長度最大32,最多顯示10條,不顯示縮略圖
或
{dede:field?name=’keywords’?function=’ShowKeyWordArc(0,32,10,0,”高三語文”)’/}
可以找到標(biāo)題里,含有“高三 語文”,或者含有“高三”或“語文”的文章
例如,這一段:
相關(guān)文章
{dede:likeart?titlelen=’24′?row=’10′} [field:textlink/] {/dede:likeart}
就改成:
相關(guān)文章
{dede:field?name=’keywords’?function=’ShowKeyWordArc(0,32,10,0,”@me”)’/}
申明:這個(gè)函數(shù)不是我寫的
根據(jù)關(guān)鍵字來相關(guān)文章,就用戶體驗(yàn)以及SEO來說都是非常好的
? 版權(quán)聲明
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載。
THE END