[BUGFIX] Sorting ignored in "Template Overview" 66/21366/6
authorReinhard Führicht <rf@typoheads.at>
Tue, 25 Jun 2013 13:41:13 +0000 (15:41 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Sat, 20 Jun 2015 14:16:16 +0000 (16:16 +0200)
The overview of all TS templates shows a tree like view listing
of all pages having a ts template on them.
But this view doesn't sort the pages by "sorting" like
in the pagetree.

Resolves: #22774
Releases: master, 6.2
Change-Id: If7279f14697aab02735da66de5cd3cb2185f2b3a
Reviewed-on: http://review.typo3.org/21366
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateModuleController.php

index 7b510bc..394be7e 100644 (file)
@@ -204,13 +204,21 @@ class TypoScriptTemplateModuleController extends BaseScriptClass {
                        $markers['CONTENT'] = $this->content;
                } else {
                        // Template pages:
-                       $db = $this->getDatabaseConnection();
-                       $res = $db->exec_SELECTquery('pages.uid, count(*) AS count, max(sys_template.root) AS root_max_val, min(sys_template.root) AS root_min_val', 'pages,sys_template', 'pages.uid=sys_template.pid' . BackendUtility::deleteClause('pages') . BackendUtility::versioningPlaceholderClause('pages') . BackendUtility::deleteClause('sys_template') . BackendUtility::versioningPlaceholderClause('sys_template'), 'pages.uid');
+                       $records = $this->getDatabaseConnection()->exec_SELECTgetRows(
+                               'pages.uid, count(*) AS count, max(sys_template.root) AS root_max_val, min(sys_template.root) AS root_min_val',
+                               'pages,sys_template',
+                               'pages.uid=sys_template.pid'
+                                       . BackendUtility::deleteClause('pages')
+                                       . BackendUtility::versioningPlaceholderClause('pages')
+                                       . BackendUtility::deleteClause('sys_template')
+                                       . BackendUtility::versioningPlaceholderClause('sys_template'),
+                               'pages.uid',
+                               'pages.pid, pages.sorting'
+                       );
                        $pArray = array();
-                       while ($row = $db->sql_fetch_assoc($res)) {
-                               $this->setInPageArray($pArray, BackendUtility::BEgetRootLine($row['uid'], 'AND 1=1'), $row);
+                       foreach ($records as $record) {
+                               $this->setInPageArray($pArray, BackendUtility::BEgetRootLine($record['uid'], 'AND 1=1'), $record);
                        }
-                       $db->sql_free_result($res);
 
                        $table = '<div class="table-fit"><table class="table table-striped table-hover" id="ts-overview">' .
                                        '<thead>' .