search
HomeCMS TutorialDEDECMSWhat should I do if DEDECMS related documents are not relevant?

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=&#39;".$url."&#39; 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=&#39;sjdqimggl&#39;><a href=&#39;".$url."&#39; target=_blank>";
  
  if ($row->litpic!="") $ss=$ss."<img  src=&#39;".$row- alt="What should I do if DEDECMS related documents are not relevant?" >litpic."&#39; alt=&#39;".$row->title."&#39; />";
  
  else $ss=$ss."<img  src=&#39;/images/titl.gif&#39;/ alt="What should I do if DEDECMS related documents are not relevant?" >";
  
  $ss=$ss."</a></span><span class=&#39;sjdqtxttl&#39;><a href=&#39;".$url."&#39; 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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools