[FEATURE] Add categories-based menu 84/23184/3
authorFrancois Suter <francois@typo3.org>
Wed, 28 Aug 2013 20:06:10 +0000 (22:06 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Thu, 29 Aug 2013 07:07:32 +0000 (09:07 +0200)
Now that system categories are activated by default for pages,
provide a simple way of display categorized pages with a new
typee of menu for the menu/sitemap content element.

The rendering uses a new type of special HMENU called "categories",
which means that it is also possible to create categories-based
menus in pure TypoScript.

Resolves: #51161
Documentation: #51162
Releases: 6.2
Change-Id: I137158f39607ad65dff13a604210a647cb8dda6f
Reviewed-on: https://review.typo3.org/23184
Reviewed-by: Mattias Nilsson
Tested-by: Mattias Nilsson
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/cms/locallang_ttc.xlf
typo3/sysext/css_styled_content/static/setup.txt
typo3/sysext/css_styled_content/static/v6.0/setup.txt
typo3/sysext/css_styled_content/static/v6.1/setup.txt
typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php
typo3/sysext/frontend/Configuration/TCA/tt_content.php
typo3/sysext/frontend/ext_tables.sql

index b9e876b..68acf9d 100644 (file)
                        <trans-unit id="menu_type.I.8" xml:space="preserve">
                                <source>Sitemaps of selected pages</source>
                        </trans-unit>
+                       <trans-unit id="menu_type.I.9" xml:space="preserve">
+                               <source>Pages for selected categories</source>
+                       </trans-unit>
                        <trans-unit id="list_type" xml:space="preserve">
                                <source>Plugin:</source>
                        </trans-unit>
                        <trans-unit id="accessibility_bypass_text" xml:space="preserve">
                                <source>Link text to bypass block</source>
                        </trans-unit>
+                       <trans-unit id="selected_categories" xml:space="preserve">
+                               <source>Selected categories</source>
+                       </trans-unit>
                        <trans-unit id="ALT.imgOptions" xml:space="preserve">
                                <source>Image Options</source>
                        </trans-unit>
index 7a50d00..27fe6cc 100644 (file)
@@ -1938,12 +1938,25 @@ tt_content.menu {
                                NO.wrapItemAndSub = <li class="csc-section">|</li>
                        }
                }
+
                # "Sitemaps of selected pages - liststyle"
                8 < .2
                8 {
                        special = directory
                        special.value.field = pages
                }
+
+               # Menu of categorized pages
+               9 < .default
+               9 {
+                       special = categories
+                       special.value.field = selected_categories
+                       special.sorting = title
+                       special.order = asc
+                       stdWrap {
+                               outerWrap = <ul class="csc-menu csc-menu-9">|</ul>
+                       }
+               }
        }
 
        20.stdWrap {
index 19acef7..ee41ce7 100644 (file)
@@ -1934,12 +1934,25 @@ tt_content.menu {
                                NO.wrapItemAndSub = <li class="csc-section">|</li>
                        }
                }
+
                # "Sitemaps of selected pages - liststyle"
                8 < .2
                8 {
                        special = directory
                        special.value.field = pages
                }
+
+               # Menu of categorized pages
+               9 < .default
+               9 {
+                       special = categories
+                       special.value.field = selected_categories
+                       special.sorting = title
+                       special.order = asc
+                       stdWrap {
+                               outerWrap = <ul class="csc-menu csc-menu-9">|</ul>
+                       }
+               }
        }
 
        20.stdWrap {
index 2bf97ef..801b159 100644 (file)
@@ -1935,12 +1935,25 @@ tt_content.menu {
                                NO.wrapItemAndSub = <li class="csc-section">|</li>
                        }
                }
+
                # "Sitemaps of selected pages - liststyle"
                8 < .2
                8 {
                        special = directory
                        special.value.field = pages
                }
+
+               # Menu of categorized pages
+               9 < .default
+               9 {
+                       special = categories
+                       special.value.field = selected_categories
+                       special.sorting = title
+                       special.order = asc
+                       stdWrap {
+                               outerWrap = <ul class="csc-menu csc-menu-9">|</ul>
+                       }
+               }
        }
 
        20.stdWrap {
index 8b22cba..8ddc2ae 100644 (file)
@@ -666,6 +666,11 @@ class AbstractMenuContentObject {
                                                        }
                                                }
                                                break;
+                                       case 'categories':
+                                               /** @var \TYPO3\CMS\Frontend\ContentObject\Menu\CategoryMenuUtility $categoryMenuUtility */
+                                               $categoryMenuUtility = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\Menu\\CategoryMenuUtility');
+                                               $temp = $categoryMenuUtility->collectPages($value, $this->conf['special.'], $this);
+                                               break;
                                        case 'rootline':
                                                $range = isset($this->conf['special.']['range.']) ? $this->parent_cObj->stdWrap($this->conf['special.']['range'], $this->conf['special.']['range.']) : $this->conf['special.']['range'];
                                                $begin_end = explode('|', $range);
@@ -1791,6 +1796,23 @@ class AbstractMenuContentObject {
                return $result;
        }
 
+       /**
+        * Returns the sys_page object
+        *
+        * @return \TYPO3\CMS\Frontend\Page\PageRepository
+        */
+       public function getSysPage() {
+               return $this->sys_page;
+       }
+
+       /**
+        * Returns the parent content object
+        *
+        * @return \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
+        */
+       public function getParentContentObject() {
+               return $this->parent_cObj;
+       }
 }
 
 
index 84f9d97..2166f91 100644 (file)
@@ -1336,6 +1336,10 @@ return array(
                                        array(
                                                'LLL:EXT:cms/locallang_ttc.xlf:menu_type.I.7',
                                                '6'
+                                       ),
+                                       array(
+                                               'LLL:EXT:cms/locallang_ttc.xlf:menu_type.I.9',
+                                               '9'
                                        )
                                ),
                                'default' => '0'
@@ -1748,6 +1752,25 @@ return array(
                                'size' => '30',
                                'max' => '255'
                        )
+               ),
+               'selected_categories' => array(
+                       'label' => 'LLL:EXT:cms/locallang_ttc.xlf:selected_categories',
+                       'config' => array(
+                               'type' => 'select',
+                               'foreign_table' => 'sys_category',
+                               'foreign_table_where' => 'AND sys_category.sys_language_uid IN (0,-1) ORDER BY sys_category.title ASC',
+                               'size' => 10,
+                               'autoSizeMax' => 50,
+                               'maxitems' => 9999,
+                               'renderMode' => 'tree',
+                               'treeConfig' => array(
+                                       'parentField' => 'parent',
+                                       'appearance' => array(
+                                               'expandAll' => TRUE,
+                                               'showHeader' => TRUE,
+                                       ),
+                               ),
+                       )
                )
        ),
        'types' => array(
@@ -1885,7 +1908,16 @@ return array(
                                --div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.extended',
                        'subtype_value_field' => 'menu_type',
                        'subtypes_excludelist' => array(
-                               '2' => 'pages'
+                               '0' => 'selected_categories',
+                               '1' => 'selected_categories',
+                               '2' => 'pages, selected_categories',
+                               '3' => 'selected_categories',
+                               '4' => 'selected_categories',
+                               '5' => 'selected_categories',
+                               '6' => 'selected_categories',
+                               '7' => 'selected_categories',
+                               '8' => 'selected_categories',
+                               '9' => 'pages',
                        )
                ),
                'mailform' => array(
@@ -2068,7 +2100,7 @@ return array(
                        'canNotCollapse' => 1
                ),
                'menu' => array(
-                       'showitem' => 'menu_type;LLL:EXT:cms/locallang_ttc.xlf:menu_type_formlabel, --linebreak--, pages;LLL:EXT:cms/locallang_ttc.xlf:pages.ALT.menu_formlabel',
+                       'showitem' => 'menu_type;LLL:EXT:cms/locallang_ttc.xlf:menu_type_formlabel, --linebreak--, pages;LLL:EXT:cms/locallang_ttc.xlf:pages.ALT.menu_formlabel, --linebreak--, selected_categories',
                        'canNotCollapse' => 1
                ),
                'menu_accessibility' => array(
index f11697f..691e7bd 100644 (file)
@@ -329,6 +329,7 @@ CREATE TABLE tt_content (
        accessibility_bypass_text varchar(30) DEFAULT '' NOT NULL,
        l18n_parent int(11) DEFAULT '0' NOT NULL,
        l18n_diffsource mediumblob,
+       selected_categories text,
 
        PRIMARY KEY (uid),
        KEY t3ver_oid (t3ver_oid,t3ver_wsid),