Home > Article > CMS Tutorial > dede:What to do if there is an error in the association between likearticle article tags and tag tags
##dede: What should I do if the likearticle article tag and tag tag are incorrectly associated?
Dreamweaver 5.7 has a dede:likearticle tag that is used to associate articles, but during the process of using it, we found that this association is really useless, but the author found that everyone is using Dreamweaver Is it still acceptable when searching for 5.7? The author replaced the search function of dede with this likearticle, and it seems to be much better. Recommended learning: Code IntroductionThe author changed the default keywords to associate articles with tags, and A judgment has been added. After executing the fuzzy query based on tags, if the query data is empty, directly query all the recommended articles under this column again. This is better, that is, there is always a return value. The author considers that some articles do not have tags, and some articles have tags but no article is found, so he first determines whether there are tags. If not, he directly queries the recommended articles in this column. If there are tags, the article is not found. If empty articles are found, recommended articles under the current column will also be returned. Solutions/steps for associating likearticle and tag tagsStep 1: Use Notepad or some tools to open the file "root directory\include\taglib\likearticle.lib.php". Step 2: Search for "['keywords']", replace all with ['tags'] and save. Computer Mutual Aid Network Note: Original code line 55: $keyword = (!empty($refObj->Fields['keywords']) ? $refObj->Fields[ 'keywords'] : '' );Original code line 75: if(!empty($refObj->Fields['keywords']))Original code line 77:$ 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)'"; "Logout at line 87 of the source code: //$keyword .= ($keyword=='' ? " CONCAT(arc.keywords,' ',arc.title) LIKE '%$k%' " : " OR CONCAT(arc.keywords,' ',arc.title) LIKE '%$k%' "); Computer Mutual Aid Network Add Code Meaning: Original Blur As for the query statement, the author added a short title here and also wanted to query it. However, I don’t like to use linke, a fuzzy query, so I changed it to REGEXP query here. Step 4: Add the following code below line 107 and save. The code is as follows:/** 按tag标签关联文章内容 query2为备用,如果query为空的话,第二个就直接显示出来 */ $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 0,$row"; $typeids=$refObj->Fields['typeid'];//取出当前栏目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('c', 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 0,$row"; /*query3是判断是否为空用的*/ $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 0,$row";//这里的SQL具体按自己的数据库的表字段写吧,我这是直接写死了,哎没办法,能力有限。 /* 这里是判断tags标签查询的是否为空值,如果是空值,就全部使用推荐返回值,如果有值,就直接显示tags关联。 */ $result =mysql_query($query3);//query36判断专用的,主要是作者不会用SetQuery呀,郁闷。我是直接拼的SQL if(mysql_num_rows($result)<1){ $dsql->SetQuery($query2); }else{ $dsql->SetQuery($query); }The following is a picture of all logouts from lines 101 to 107 of the source code. Click on the picture to see a larger picture: The meaning of the above code: Query2 associated with article content by tag tag is a backup. If the data queried by tags tag is empty, the second one can be used. Step 5: Add the following code under line 117 of the original code and save. The code is as follows:
$typeids=$refObj->Fields['typeid'];//取出当前栏目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('c', 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 0,$row"; $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: The fifth step is to check when the tags tag has content. The fifth step is the SQL executed when the tags tag is not empty. Step 6: After completion, upload it to the space. The author will not demonstrate the effect of the code. If you really want to see the effect, just read the related articles 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
The above is the detailed content of dede:What to do if there is an error in the association between likearticle article tags and tag tags. For more information, please follow other related articles on the PHP Chinese website!