Sorting in article category had no effect
authorMarcel Werk <burntime@woltlab.com>
Mon, 28 Jun 2021 15:25:12 +0000 (17:25 +0200)
committerMarcel Werk <burntime@woltlab.com>
Mon, 28 Jun 2021 15:25:12 +0000 (17:25 +0200)
wcfsetup/install/files/lib/page/CategoryArticleListPage.class.php

index 08a4ec37ad23dba8d28f579830efa70e4aa73420..17d8268239aefd76d904aa99a9d9ede60cef8bb7 100644 (file)
@@ -52,14 +52,8 @@ class CategoryArticleListPage extends ArticleListPage {
                ], ($this->pageNo > 1 ? 'pageNo=' . $this->pageNo : ''));
                
                if ($this->category->sortField) {
-                       if ($this->category->sortField === 'title') {
-                               $this->sortField = 'article_content.title';
-                               $this->sortOrder = $this->category->sortOrder;
-                       }
-                       else {
-                               $this->sortField = $this->category->sortField;
-                               $this->sortOrder = $this->category->sortOrder;
-                       }
+                       $this->sortField = $this->category->sortField;
+                       $this->sortOrder = $this->category->sortOrder;
                }
        }
        
@@ -80,14 +74,11 @@ class CategoryArticleListPage extends ArticleListPage {
         */
        protected function initObjectList() {
                $this->objectList = new CategoryArticleList($this->categoryID, true);
-               if ($this->category->sortField === 'title') {
-                       $this->objectList->sqlJoins .= ' LEFT JOIN wcf' . WCF_N . '_article_content article_content ON (article_content.articleID = article.articleID AND (
-                               article_content.languageID IS NULL
-                               OR article_content.languageID = ' . WCF::getLanguage()->languageID . '
-                       ))';
-               }
-               
                $this->applyFilters();
+               
+               if ($this->sortField === 'title') {
+                       $this->objectList->sqlSelects = "(SELECT title FROM wcf".WCF_N."_article_content WHERE articleID = article.articleID AND (languageID IS NULL OR languageID = ".WCF::getLanguage()->languageID.") LIMIT 1) AS title";
+               }
        }
        
        /**