From 2dc348454df059480fa0068f210744230a0f7d0f Mon Sep 17 00:00:00 2001 From: eSilverStrike Date: Wed, 25 Mar 2020 13:31:14 -0400 Subject: [PATCH] Fixed Related Articles not appearing on article page For bug #1048 - Related Articles now appear if the article has meta keywords - Now searches for the last 50 articles that have a matching keyword and is ordered by date - lower case all keywords - Mentioned Related Articles Feature in Meta Tags Config description --- public_html/docs/english/config.html | 5 ++--- public_html/docs/history | 1 + public_html/docs/japanese/config.html | 5 ++--- public_html/docs/japanese/history.html | 1 + system/classes/article.class.php | 13 +++++++++---- system/lib-article.php | 2 +- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/public_html/docs/english/config.html b/public_html/docs/english/config.html index 99d836248..c6f208f59 100644 --- a/public_html/docs/english/config.html +++ b/public_html/docs/english/config.html @@ -113,9 +113,8 @@

Site: Site

meta_tags Disabled - Enabled - The meta tags for articles and topics will be displayed. If none are found, then the default will be used. The default will also be used for any page that doesn't have meta tags.
- Enabled (Default for Homepage only) - The same as Enabled except, the defaults are used only for the Homepage.
- Disabled - Meta tags are not used. + If "Enabled" (1) the meta tags for articles and topics will be displayed. If none are found, then the default will be used. The default will also be used for any page that doesn't have meta tags. If + "Enabled (Default for Homepage only)" (2) then it behaves the same as "Enabled" except, the defaults are used only for the Homepage. If "Disabled" (0) then Meta tags are not used.

Please note, if enabled and the article has it's own meta keywords then the article page will also display a list of up to 5 related articles (displayed under the title "You might also like"). This relation is based on how many keywords the article shares with others and how new the other articles are. meta_description 'Geeklog, the open source content management system designed with security in mind.' diff --git a/public_html/docs/history b/public_html/docs/history index 715de4c87..9ab77476d 100644 --- a/public_html/docs/history +++ b/public_html/docs/history @@ -20,6 +20,7 @@ For more in-depth explanation of the issues below see: https://github.com/Geeklo - [Bug] [#1044] Fixed searching just articles [Tom] - [Bug] [#1046] Fixed Users can only be set to certain statuses by Admins [Tom] - [Bug] [#1047] Fixed Admin login form for those who try to access the Geeklog Admin area. Regular Logged in Users get just a message now instead of showing a login form [Tom] +- [Bug] [#1048] Fixed related Articles are Missing From the Article Page [Tom] The following items are all current Geeklog API, functions, and/or global variables that are planned to be either required or depreciated by a current Geeklog version. Plugin and Theme developers please take note of these changes in case they affect you. diff --git a/public_html/docs/japanese/config.html b/public_html/docs/japanese/config.html index dfa7d7513..f0bd66d3f 100644 --- a/public_html/docs/japanese/config.html +++ b/public_html/docs/japanese/config.html @@ -101,9 +101,8 @@

サイト: サイト

メタタグ(meta_tags) 無効にする - + If "Enabled" (1) the meta tags for articles and topics will be displayed. If none are found, then the default will be used. The default will also be used for any page that doesn't have meta tags. If + "Enabled (Default for Homepage only)" (2) then it behaves the same as "Enabled" except, the defaults are used only for the Homepage. If "Disabled" (0) then Meta tags are not used.

Please note, if enabled and the article has it's own meta keywords then the article page will also display a list of up to 5 related articles (displayed under the title "You might also like"). This relation is based on how many keywords the article shares with others and how new the other articles are. サイトの説明文のメタタグ(meta_description) 'Geeklog, the open source content management system designed with security in mind.' diff --git a/public_html/docs/japanese/history.html b/public_html/docs/japanese/history.html index 3b9ac3da7..a251aaf4e 100644 --- a/public_html/docs/japanese/history.html +++ b/public_html/docs/japanese/history.html @@ -46,6 +46,7 @@

March ? 2020 (2.2.1sr1)

  • [Bug] [#1044] Fixed searching just articles [Tom]
  • [Bug] [#1046] Fixed Users can only be set to certain statuses by Admins [Tom]
  • [Bug] [#1047] Fixed Admin login form for those who try to access the Geeklog Admin area. Regular Logged in Users get just a message now instead of showing a login form [Tom]
  • +
  • [Bug] [#1048] Fixed related Articles are Missing From the Article Page [Tom]
  • The following items are all current Geeklog API, functions, and/or global variables that are planned to be either required or depreciated by a current Geeklog version. Plugin and Theme developers please take note of these changes in case they affect you.
    diff --git a/system/classes/article.class.php b/system/classes/article.class.php index 9740f418d..8cfa962f0 100644 --- a/system/classes/article.class.php +++ b/system/classes/article.class.php @@ -2021,7 +2021,7 @@ private static function getRelatedArticlesSort(array $a, array $b) * * @param string $articleId * @param string $keywordList a comma-separated list of keywords - * @param int $limit max number od related articles + * @param int $limit max number of related articles returned * @return array * @link http://www.enkeladress.com/article/20110315104621317 */ @@ -2031,6 +2031,10 @@ public static function getRelatedArticlesByKeywords($articleId, $keywordList, $l $work = array(); + // Lets search the 50 latest articles that match the keyword + // This will return the most related + $searchlimit = 50; + $articleId = trim($articleId); $keywords = explode(',', $keywordList); @@ -2053,9 +2057,10 @@ public static function getRelatedArticlesByKeywords($articleId, $keywordList, $l $sql = "SELECT sid, title FROM {$_TABLES['stories']} " . "WHERE (sid <> '{$escapedArticleId}') " . "AND (draft_flag = 0) AND (date <= NOW()) " - . "AND meta_keywords LIKE '%{$escapedKeyword}%' " + . "AND LOWER(meta_keywords) LIKE LOWER('%{$escapedKeyword}%') " . "GROUP BY sid, title " - . "LIMIT 5 "; + . "ORDER BY date DESC " + . "LIMIT $searchlimit "; $resultSet = DB_query($sql); while (($A = DB_fetchArray($resultSet, false)) !== false) { @@ -2083,7 +2088,7 @@ public static function getRelatedArticlesByKeywords($articleId, $keywordList, $l } $retval = ''; - if ($found) { + if (count($work) > 0) { if (count($work) > 1) { usort($work, array(__CLASS__, 'getRelatedArticlesSort')); } diff --git a/system/lib-article.php b/system/lib-article.php index 774ee9fe8..572ed3562 100644 --- a/system/lib-article.php +++ b/system/lib-article.php @@ -655,7 +655,7 @@ function STORY_renderArticle($story, $index = '', $storyTpl = 'articletext.thtml } // Add related articles - if ($index === 'n') { + if ($index === 'n' && $_CONF['meta_tags'] > 0) { $article->set_var( 'related_articles_by_keyword', Article::getRelatedArticlesByKeywords(