[FEATURE] Allow to sort subpages by nav title 66/56866/2
authorBenni Mack <benni@typo3.org>
Sat, 5 May 2018 20:50:40 +0000 (22:50 +0200)
committerBenni Mack <benni@typo3.org>
Sun, 6 May 2018 14:24:42 +0000 (16:24 +0200)
The sort-subpages functionality available in the
context menu of a page now also allows to sort by
nav_title.

This also fixes a typo ("create" instead of "crdate") and
streamlines some templating functionality.

Resolves: #84932
Releases: master
Change-Id: I5a59745214c7cb1682e652efb865fcd949a0e413
Reviewed-on: https://review.typo3.org/56866
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/backend/Classes/Controller/Page/SortSubPagesController.php
typo3/sysext/backend/Resources/Private/Language/locallang_pages_sort.xlf
typo3/sysext/backend/Resources/Private/Templates/Page/SortSubPages.html
typo3/sysext/core/Documentation/Changelog/master/Feature-84932-SortSubpagesByNavTitle.rst [new file with mode: 0644]

index c0b0363..bc34c56 100644 (file)
@@ -105,7 +105,7 @@ class SortSubPagesController
         if (!$isInWorkspace) {
             // Apply new sorting if given
             $newSortBy = $request->getQueryParams()['newSortBy'] ?? null;
-            if ($newSortBy && in_array($newSortBy, ['title', 'subtitle', 'crdate', 'tstamp'], true)) {
+            if ($newSortBy && in_array($newSortBy, ['title', 'subtitle', 'nav_title', 'crdate', 'tstamp'], true)) {
                 $this->sortSubPagesByField($parentPageUid, (string)$newSortBy);
             } elseif ($newSortBy && $newSortBy === 'reverseCurrentSorting') {
                 $this->reverseSortingOfPages($parentPageUid);
@@ -144,9 +144,9 @@ class SortSubPagesController
      */
     protected function sortSubPagesByField(int $parentPageUid, string $newSortBy)
     {
-        if (!in_array($newSortBy, ['title', 'subtitle', 'crdate', 'tstamp'], true)) {
+        if (!in_array($newSortBy, ['title', 'subtitle', 'nav_title', 'crdate', 'tstamp'], true)) {
             throw new \RuntimeException(
-                'New sort by must be one of "title", "subtitle", "crdate" or tstamp',
+                'New sort by must be one of "title", "subtitle", "nav_title", "crdate" or tstamp',
                 1498924810
             );
         }
index 41e0f46..97569f7 100644 (file)
@@ -22,6 +22,9 @@
                        <trans-unit id="fieldSubtitle">
                                <source>Subtitle</source>
                        </trans-unit>
+                       <trans-unit id="fieldNavitle">
+                               <source>Navigation title</source>
+                       </trans-unit>
                        <trans-unit id="fieldCrdate">
                                <source>Create-time</source>
                        </trans-unit>
@@ -35,6 +38,9 @@
                        <trans-unit id="changeOrderBySubtitle">
                                <source>Subtitle</source>
                        </trans-unit>
+                       <trans-unit id="changeOrderByNavtitle">
+                               <source>Navigation title</source>
+                       </trans-unit>
                        <trans-unit id="changeOrderByTstamp">
                                <source>Change-time</source>
                        </trans-unit>
index df00cd3..031c50b 100644 (file)
@@ -9,14 +9,14 @@
 />
 
 <h1>
-    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:title" />
+    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:title" />
 </h1>
 
 <f:if condition="{isInWorkspace}">
     <f:then>
         <f:be.infobox
-            title="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:notAvailableInWorkspace.title')}"
-            message="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:notAvailableInWorkspace.message')}"
+            title="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:notAvailableInWorkspace.title')}"
+            message="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:notAvailableInWorkspace.message')}"
             state="-1"
         />
     </f:then>
             <f:then>
                 <f:if condition="{hasInvisiblePage}">
                     <f:be.infobox
-                        title="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:hasInvisiblePage.title')}"
-                        message="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:hasInvisiblePage.message')}"
+                        title="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:hasInvisiblePage.title')}"
+                        message="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:hasInvisiblePage.message')}"
                         state="-1"
                     />
                 </f:if>
 
                 <h2>
-                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:currentPageOrder" />
+                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:currentPageOrder" />
                 </h2>
 
                 <div class="table-fit">
                         <thead>
                             <tr>
                                 <th>
-                                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:fieldTitle" />
+                                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:fieldTitle" />
                                 </th>
                                 <th>
-                                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:fieldSubtitle" />
+                                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:fieldSubtitle" />
                                 </th>
                                 <th>
-                                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:fieldTstamp" />
+                                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:fieldNavTitle" />
                                 </th>
                                 <th>
-                                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:fieldCrdate" />
+                                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:fieldTstamp" />
+                                </th>
+                                <th>
+                                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:fieldCrdate" />
                                 </th>
                             </tr>
                         </thead>
@@ -61,7 +64,7 @@
                                     <f:if condition="!{page.canEdit}">
                                         <span
                                             data-toggle="tooltip"
-                                            data-title="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:noEditPermissions')}"
+                                            data-title="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:noEditPermissions')}"
                                         >
                                             <core:icon identifier="status-status-permission-denied" />
                                         </span>
@@ -72,6 +75,9 @@
                                     {page.record.subtitle -> f:format.crop(maxCharacters: maxTitleLength)}
                                 </td>
                                 <td class="text-nowrap">
+                                    {page.record.nav_title -> f:format.crop(maxCharacters: maxTitleLength)}
+                                </td>
+                                <td class="text-nowrap">
                                     <f:format.date format="{dateFormat} {timeFormat}">{page.record.tstamp}</f:format.date>
                                 </td>
                                 <td class="text-nowrap">
                 </div>
 
                 <h2>
-                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:changeOrder"/>
+                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrder"/>
                 </h2>
                 <a class="btn btn-default t3js-modal-trigger"
                     href="{be:moduleLink(route:'pages_sort', arguments:'{id:parentPageUid, newSortBy:\'title\'}')}"
                     data-severity="warning"
                     data-title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:pleaseConfirm')}"
                     data-button-close-text="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')}"
-                    data-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:changeOrderConfirm')}"
+                    data-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderConfirm')}"
                 >
-                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:changeOrderByTitle" />
+                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderByTitle" />
                 </a>
                 <a class="btn btn-default t3js-modal-trigger"
                     href="{be:moduleLink(route:'pages_sort', arguments:'{id:parentPageUid, newSortBy:\'subtitle\'}')}"
                     data-severity="warning"
                     data-title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:pleaseConfirm')}"
                     data-button-close-text="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')}"
-                    data-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:changeOrderConfirm')}"
+                    data-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderConfirm')}"
+                >
+                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderBySubtitle" />
+                </a>
+                <a class="btn btn-default t3js-modal-trigger"
+                    href="{be:moduleLink(route:'pages_sort', arguments:'{id:parentPageUid, newSortBy:\'nav_title\'}')}"
+                    data-severity="warning"
+                    data-title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:pleaseConfirm')}"
+                    data-button-close-text="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')}"
+                    data-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderConfirm')}"
                 >
-                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:changeOrderBySubtitle" />
+                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderByNavtitle" />
                 </a>
                 <a class="btn btn-default t3js-modal-trigger"
                     href="{be:moduleLink(route:'pages_sort', arguments:'{id:parentPageUid, newSortBy:\'tstamp\'}')}"
                     data-severity="warning"
                     data-title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:pleaseConfirm')}"
                     data-button-close-text="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')}"
-                    data-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:changeOrderConfirm')}"
+                    data-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderConfirm')}"
                 >
-                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:changeOrderByTstamp" />
+                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderByTstamp" />
                 </a>
                 <a class="btn btn-default t3js-modal-trigger"
                     href="{be:moduleLink(route:'pages_sort', arguments:'{id:parentPageUid, newSortBy:\'create\'}')}"
                     data-severity="warning"
                     data-title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:pleaseConfirm')}"
                     data-button-close-text="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')}"
-                    data-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:changeOrderConfirm')}"
+                    data-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderConfirm')}"
                 >
-                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:changeOrderByCreate" />
+                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderByCreate" />
                 </a>
                 <a class="btn btn-default t3js-modal-trigger"
                     href="{be:moduleLink(route:'pages_sort', arguments:'{id:parentPageUid, newSortBy:\'reverseCurrentSorting\'}')}"
                     data-severity="warning"
                     data-title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:pleaseConfirm')}"
                     data-button-close-text="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')}"
-                    data-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:changeOrderConfirm')}"
+                    data-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderConfirm')}"
                 >
-                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:changeOrderReverse" />
+                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderReverse" />
                 </a>
             </f:then>
             <f:else>
                 <f:be.infobox
-                    title="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:noSubpages.title')}"
-                    message="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort:noSubpages.message')}"
+                    title="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:noSubpages.title')}"
+                    message="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:noSubpages.message')}"
                     state="-1"
                 />
             </f:else>
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-84932-SortSubpagesByNavTitle.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-84932-SortSubpagesByNavTitle.rst
new file mode 100644 (file)
index 0000000..051415d
--- /dev/null
@@ -0,0 +1,15 @@
+.. include:: ../../Includes.txt
+
+============================================
+Feature: #84932 - Sort subpages by nav_title
+============================================
+
+See :issue:`84932`
+
+Description
+===========
+
+Sorting subpages of a page - available via the Context Menu of a page - allows to sort by the `nav_title` database
+field called "Alternative Navigation Title".
+
+.. index:: Backend
\ No newline at end of file