GetKeywordSql.." and save it."/> GetKeywordSql.." and save it.">

Home  >  Article  >  CMS Tutorial  >  What should I do if dede5.7 free list cannot obtain multiple keywords?

What should I do if dede5.7 free list cannot obtain multiple keywords?

藏色散人
藏色散人Original
2019-12-16 10:23:351916browse

What should I do if dede5.7 free list cannot obtain multiple keywords?

dede5.7 Free list cannot obtain multiple keywords?

This article has compiled a complete solution to the problem of dede5.7 free list not being able to obtain multiple keywords, as well as alternative usage techniques. Friends in need can learn from it.

Recommended learning: 梦Weavercms

Let’s first take a look at the interface for adding a free list in DEDE5.7.

What should I do if dede5.7 free list cannot obtain multiple keywords?

We can see in the picture that under normal circumstances, DEDE officially writes that multiple keywords can be used: keyword 1, keyword 2, keyword 3... , but I don’t know if it is an official mistake or for other reasons. After adding multiple keywords, it has no effect. Instead, no content can be retrieved. Based on the problems reported by everyone, we have compiled a complete solution to this problem. method.

Involved files: Replace include\arc.freelist.class.php

What should I do if dede5.7 free list cannot obtain multiple keywords?

We can see that the involved code is as shown in the picture above.

Let’s hide the two codes first!

We will write a related statement ourselves:

$orwhere .=  "AND (".$this->GetKeywordSql($keyword)." )";

Finally, we will find the location below and add the relevant search conditions and rules we wrote

function GetKeywordSql($keyword)
    {
        $ks = explode(',',$keyword);
        $kwsql = '';
        $kwsqls = array();
        foreach($ks as $k)
        {
            $k = trim($k);
            if(strlen($k)<1)
            {
                continue;
            }
            if(ord($k[0])>0x80 && strlen($k)<2)
            {
                continue;
            }
            $k = addslashes($k);
            $kwsqls[] = " arc.title LIKE &#39;%$k%&#39; ";
        }
        if(!isset($kwsqls[0]))
        {
            return &#39;&#39;;
        }
        else
        {
            $kwsql = join(&#39; OR &#39;,$kwsqls);
            return $kwsql;
        }
    }
    /**
     *  获得关键字SQL,统计记录使用
     *
     * @access    private
     * @return    string
     */
    function GetRowSql($keyword)
    {
        $ks = explode(&#39;,&#39;,$keyword);
        $kwsql = &#39;&#39;;
        $kwsqls = array();
        foreach($ks as $k)
        {
            $k = trim($k);
            if(strlen($k)<1)
            {
                continue;
            }
            if(ord($k[0])>0x80 && strlen($k)<2)
            {
                continue;
            }
            $k = addslashes($k);
            $kwsqls[] = " title LIKE &#39;%$k%&#39; ";
        }
        if(!isset($kwsqls[0]))
        {
            return &#39;&#39;;
        }
        else
        {
            $kwsql = join(&#39; OR &#39;,$kwsqls);
            return $kwsql;
        }

Add the above code to the bottom of the page, and now the multiple keyword function of DEDE's free list can be used!

It’s not over yet! The editor encountered a problem during the actual testing process. We added two keywords. Is that to allow further filtering, or to add broader keywords? This problem has troubled me for a long time. Through the above code, I tested the relevant solution:

What should I do if dede5.7 free list cannot obtain multiple keywords?

We can see that in this place, if we use "OR" means or, that is, we say that the scope of the search is expanded, so that articles with keywords that appear will appear. If we change to "AND", it means narrowing the scope of the search, indicating that there are already key words in the article. Word 1 must also have keyword 2.

The above is the detailed content of What should I do if dede5.7 free list cannot obtain multiple keywords?. 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