Feature #8623: Shortcut mode: add "parent page" (Thanks to Georg Ringer)
authorSteffen Gebert <steffen.gebert@typo3.org>
Sun, 5 Sep 2010 14:55:39 +0000 (14:55 +0000)
committerSteffen Gebert <steffen.gebert@typo3.org>
Sun, 5 Sep 2010 14:55:39 +0000 (14:55 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@8762 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
NEWS.txt
t3lib/class.t3lib_page.php
typo3/sysext/cms/ext_tables.php
typo3/sysext/cms/locallang_tca.xml
typo3/sysext/cms/tslib/class.tslib_fe.php

index c0775f4..5d69142 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2010-09-05  Steffen Gebert  <steffen@steffen-gebert.de>
 
        * Fixed bug #15562: PHP warning for str_pad() in t3lib_div::cmpIPv4() (Thanks to Markus Klein)
+       * Feature #8623: Shortcut mode: add "parent page" (Thanks to Georg Ringer)
 
 2010-09-04  Stanislas Rolland  <typo3@sjbr.ca>
 
index 41a440e..57a0d96 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -13,6 +13,8 @@ General
        * When TYPO3 runs with two different domain names for the FE and the BE,
          it is now possible to set accordingly different cookie domains using
          $TYPO3_CONF_VARS['FE']['cookieDomain'] and $TYPO3_CONF_VARS['BE']['cookieDomain'].
+       * Pages of type "Shortcut" can now also link to the parent page, not only to the
+         first or a random subpage.
 
 
 Backend
index dd6cfaa..bedf096 100644 (file)
@@ -516,13 +516,19 @@ class t3lib_pageSelect {
 
                                        // if shortcut, look up if the target exists and is currently visible
                                if ($row['doktype'] == 4 && ($row['shortcut'] || $row['shortcut_mode']) && $checkShortcuts)     {
-                                       if ($row['shortcut_mode'] == 0) {
+                                       if ($row['shortcut_mode'] == 0) {
+                                                       // no shortcut_mode set, so target is directly set in $row['shortcut']
                                                $searchField = 'uid';
                                                $searchUid = intval($row['shortcut']);
-                                       } else { // check subpages - first subpage or random subpage
+                                       } elseif ($row['shortcut_mode'] == 1 || $row['shortcut_mode'] == 2) {
+                                                       // check subpages - first subpage or random subpage
                                                $searchField = 'pid';
                                                        // If a shortcut mode is set and no valid page is given to select subpags from use the actual page.
                                                $searchUid = intval($row['shortcut'])?intval($row['shortcut']):$row['uid'];
+                                       } elseif ($row['shortcut_mode'] == 3) {
+                                                       // shortcut to parent page
+                                               $searchField = 'uid';
+                                               $searchUid = $row['pid'];
                                        }
                                        $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
                                                'uid',
index cc79fa7..f5f1515 100755 (executable)
@@ -326,6 +326,7 @@ if (TYPO3_MODE == 'BE') {
                                        array('', 0),
                                        array('LLL:EXT:cms/locallang_tca.xml:pages.shortcut_mode.I.1', 1),
                                        array('LLL:EXT:cms/locallang_tca.xml:pages.shortcut_mode.I.2', 2),
+                                       array('LLL:EXT:cms/locallang_tca.xml:pages.shortcut_mode.I.3', 3),
                                ),
                                'default' => '0'
                        )
index ffc648c..6d8f484 100755 (executable)
@@ -55,6 +55,7 @@
                        <label index="pages.shortcut_mode">Shortcut mode:</label>
                        <label index="pages.shortcut_mode.I.1">First subpage</label>
                        <label index="pages.shortcut_mode.I.2">Random subpage</label>
+                       <label index="pages.shortcut_mode.I.3">Parent page</label>
                        <label index="pages.content_from_pid">Show content from this page instead:</label>
                        <label index="pages.mount_pid">Mount Point (advanced):</label>
                        <label index="pages.mount_pid_ol">Substitute Mount Point (this page) with Mounted page:</label>
index 553835b..95600aa 100644 (file)
         * Get page shortcut; Finds the records pointed to by input value $SC (the shortcut value)
         *
         * @param       integer         The value of the "shortcut" field from the pages record
-        * @param       integer         The shortcut mode: 1 and 2 will select either first subpage or random subpage; the default is the page pointed to by $SC
+        * @param       integer         The shortcut mode: 1 will select first subpage, 2 a random subpage, 3 the parent page; default is the page pointed to by $SC
         * @param       integer         The current page UID of the page which is a shortcut
         * @param       integer         Safety feature which makes sure that the function is calling itself recursively max 20 times (since this function can find shortcuts to other shortcuts to other shortcuts...)
         * @param       array           An array filled with previous page uids tested by the function - new page uids are evaluated against this to avoid going in circles.
                                        $c++;
                                }
                        break;
+                       case 3:
+                               $parent = $this->sys_page->getPage($thisUid);
+                               $page = $this->sys_page->getPage($parent['pid']);
+                       break;
                        default:
                                $page = $this->sys_page->getPage($idArray[0]);
                        break;