In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article is about solving the problem of association errors between dede:likearticle article tags and tag tags. 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.
What about the association error between the dede:likearticle article tag and the tag tag?
Dream weaving 5.7.There is a dede:likearticle tag for the association of articles, but in the process of using it, we find that this association is really chicken ribs, but the author finds that people can reluctantly accept it when searching with dream weaving 5.7s. The author replaces the search function of dede with this likearticle, which does look much better.
Code introduction
The author changes the default keywords keyword to associate articles with tags, and adds a judgment. After executing the fuzzy query with tags, if the query data is empty, then directly query all the recommended articles under this column again directly. This is better, that is to keep the return value all the time.
The author takes into account that some articles do not have tags, while some articles have tags but did not query the article, so first determine whether there is a tags if not directly query the recommended articles under this column, if there is an tags tag but query the empty articles, then also return the recommended articles under the current column.
Likearticle and tag tag association workaround / step
Step 1: use notepad or some tools to open the file "root directory\ include\ taglib\ likearticle.lib.php".
Step 2: search for "['keywords']", replace it all with [' tags'] and save it.
Computer Mutual Assistance Network Note;
Line 55 of the original code: $keyword = (! empty ($refObj- > Fields ['keywords'])? $refObj- > Fields [' keywords']:')
Original code 75 lines: if (! empty ($refObj- > Fields ['keywords']))
Line 77 of original code: $keywords = explode (',', trim ($refObj- > Fields ['keywords']))
Step 3: add "$keyword. = $keyword==''?" under line 87. CONCAT (arc.title,arc.keywords,arc.shorttitle) REGEXP'($k)'":" OR CONCAT (arc.title,arc.keywords,arc.shorttitle) REGEXP'($k)'";"
Line 87 of the source code logs out: / / $keyword. = ($keyword==''? "CONCAT (arc.keywords,'', arc.title) LIKE'% $k%'": "OR CONCAT (arc.keywords,'', arc.title) LIKE'% $k%'")
Computer mutual help network to add code meaning: the original fuzzy query statement, the author added a short title here also want to query, but I do not like to use linke this fuzzy query, so here replaced by REGEXP query.
Step 4: add the following code below line 107 and save it.
The code is as follows:
/ * * Associate article content query2 by tag tag. If query is empty, the second one will be directly displayed * / $query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule, tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath FROM `dede_ archives`arc LEFT JOIN `dede_ arctype` tp on arc.typeid=tp.id WHERE $keyword and arc.ismake = 1 and arc.id $arcid ORDER BY arc.sortrank desc LIMIT 0sparrow" $typeids=$refObj- > Fields ['typeid'] / / take out the current column ID$query2 = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule, tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath FROM `dede_ archives` arc LEFT JOIN `dede_ arctype` tp on arc.typeid=tp.id WHERE FIND_IN_SET ('caching, arc.flag) > 0 and arc.ismake = 1 And (arc.typeid in ($typeids) or arc.typeid2 in ($typeids) or CONCAT (',', arc.typeid2,' ') LIKE'%, $typeids,%') And arc.arcrank >-1 ORDER BY arc.sortrank desc LIMIT 0recoveryrow " / * query3 is used to determine whether it is empty or not * / $query3 = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule, tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath FROM dede_archives arc LEFT JOIN dede_arctype tp on arc.typeid=tp.id WHERE $keyword and arc.ismake = 1 and arc.id $arcid ORDER BY arc.sortrank desc LIMIT 0sparrow" / / the SQL here is specifically written according to the table field of your own database. I am writing it directly. Ah, there is no way, and the ability is limited. / * this is to determine whether the value queried by the tags tag is null. If so, all the recommended return values are used. If there is a value, the tags association is displayed directly. * / $result = mysql_query ($query3); / / for query36 judgment, mainly because the author does not know how to use SetQuery, depressed. I spell SQLif (mysql_num_rows ($result) SetQuery ($query2) directly;} else {$dsql- > SetQuery ($query);}
The following is a picture of all logos from lines 101 to 107 of the source code. Click on the picture to see a larger picture:
The above code means: press the tag tag to associate the article content query2 as a standby, if the data queried by the tags tag is empty, the second can be used.
Step 5: add the following code under line 117 of the original code and save it.
The code is as follows:
$typeids=$refObj- > Fields ['typeid'] / / take out the current column ID$query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule, tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath FROM `dede_ archives` arc LEFT JOIN `dede_ arctype` tp on arc.typeid=tp.id WHERE FIND_IN_SET ('caching, arc.flag) > 0 and arc.ismake = 1 And (arc.typeid in ($typeids) or arc.typeid2 in ($typeids) or CONCAT (',', arc.typeid2,' ') LIKE'%, $typeids,%') And arc.arcrank >-1 ORDER BY arc.sortrank desc LIMIT 0recoveryrow " $dsql- > SetQuery ($query)
The following is a picture of all logouts from lines 111 to 117 of the source code. Click on the picture to see a larger picture:
The meaning of the above code: step 5 is to check when the tags tag has content, step 5 is to execute the SQL when the tags tag is not empty.
Step 6: after completion and upload to the space, the author will not demonstrate the effect after the code. If you do not want to see the effect, please read the relevant article on the right side of this article.
Because some netizens are not sensitive to SQL, they may think that they can't understand anything written in this article, and they can't change it. It doesn't matter, this is the download address: likearticle.lib.rar.
Thank you for reading! On solving the problem of dede:likearticle article tags and tag tags associated errors is shared 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.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.