Home > Article > CMS Tutorial > What should I do if DEDECMS related documents are not relevant?
What should I do if the DEDECMS related documents are not relevant?
DEDE related articles are completely irrelevant. I have friends in DEDE The official release of related articles based on TAG is also very good. Unfortunately, after I change the DEDE code based on the article there, it always fails. It may be due to limited ability, of course, there may also be a problem with the code
Recommended study: 伟梦cms
Now we finally have a solution
1. Add
//查询指定栏目里包含相应关键字的文章,并列出 //参数说明:$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[] = " (dede_archives.title like '%$k%') "; //$kwsqlarr[] = " (dede_archives.keywords like '%$k%') "; //如果需要相关到其它文章的关键字,解除此行注释 } } $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."<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>"; if ($row->litpic!="") $ss=$ss."<img src='".$row->litpic."' alt='".$row->title."' />"; else $ss=$ss."<img src='/images/titl.gif'/>"; $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; }
at the end of inc_functions.php?> 2. Place it on the article template page Inside
{dede:field name=’keywords’ function=’ShowKeyWordArc(0,32,10,0,”@me”)’/}
means that relevant articles in all columns (related to the keywords of the current article) are fetched. The maximum title length is 32, and a maximum of 10 items are displayed. Thumbnails are not displayed
or
{dede:field name=’keywords’ function=’ShowKeyWordArc(0,32,10,0,”高三语文”)’/}
You can find articles that contain "High School Chinese" in the title, or contain "High School" or "Chinese"
For example, this paragraph:
Related articles
{dede:likeart titlelen=’24′ row=’10′} [field:textlink/]< > {/dede:likeart}
Change it to:
Related articles
{dede:field name=’keywords’ function=’ShowKeyWordArc(0,32,10,0,”@me”)’/}
Disclaimer: This function was not written by me
Related articles based on keywords, user experience and SEO They say they are all very good
The above is the detailed content of What should I do if DEDECMS related documents are not relevant?. For more information, please follow other related articles on the PHP Chinese website!