Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of modifying related articles in DEDECMS with keywords

Shulou Source: shulou.com Published: 2022-06-02 03:35:24 10月05日 Update

This article is to share with you about the keyword modification of DEDECMS-related articles. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.

How to modify DEDECMS related articles with keywords?

The related articles of DEDE are completely irrelevant. It is also very good for a friend to show the relevant articles according to TAG in DEDE. unfortunately, after I change the DEDE code according to the article over there, it may be that the ability is limited, of course, there may be something wrong with the code.

Now there is finally a solution:

1 add before the last? > of inc_functions.php

The code is as follows:

/ / query articles with corresponding keywords in the specified column, and list / / parameter description: whether $showImg displays thumbnails, 0 means not, 1 indicates display / / $titleLen title length, 0 indicates infinite / / $rowCount output lines, 0 indicates infinite / / $typeid column ID,0 represents all columns / / $keyWord keywords, string function ShowKeyWordArc ($showImg,$titleLen,$rowCount,$typeid,$keyWord) {$dsql = new DedeSql (false) $sql = TypeGetSunID ($typeid,$dsql)

/ / keyword segmentation technology $ks = explode ("", $keyWord); foreach ($ks as $k) {$k = trim ($k); if ($k = ") {$kwsqlarr [] =" (xkzzz_archives.title like'% $k%') "; / / $kwsqlarr [] =" (xkzzz_archives.keywords like'% $k%') "; / / if you need keywords related to other articles, uncomment this line} $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= ""; $iTun0 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. "; if ($titleLeniness0) $ss=$ss.cn_substr ($row- > title,$titleLen); else $ss=$ss.$row- > title; $ss=$ss.";} else {$ss=$ss. ""

If ($row- > litpicures = "") $ss=$ss. "

".$row-title."

"else $ss=$ss."

"; $ss=$ss."; if ($titleLeninghouse 0) $ss=$ss.cn_substr ($row- > title,$titleLen); else $ss=$ss.$row- > title; $ss=$ss. "";} $iComplete; if ($rowCountCountCountCountCountCounting room0) & & ($I > = $rowCount)) return $ss;} return $ss;}

2 put it in the article template page

{dede:field name='keywords' function='ShowKeyWordArc (0pr 32je 10je 0, "@ me")'/}

It means to take the relevant articles in all columns (related to the keywords of the current article). The maximum length of the title is 32, with a maximum of 10 items displayed, and no thumbnails are displayed.

Or

{dede:field name='keywords' function='ShowKeyWordArc (0pr 32, 10pm 0, "Senior three Chinese")'/}

You can find articles in the title that contain "Senior three Chinese" or "Senior three" 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 (0pc32, 10jin0, "@ me")'/}

Disclaimer: this function is not written by me according to keywords, but is very good in terms of user experience and SEO

But the only bad thing is that it is much slower to generate static. Haha, the server has to work hard again.

Thank you for reading! About DEDECMS related articles to keyword modification method to share here, I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.

Tags: Article key keyword column code title Chinese senior three method good content more length no practical maximum bad function method parameter Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Apple macOS Shulou Information Linux