From 65df3177f88210db31d4f90408e9ceb1f3c05f48 Mon Sep 17 00:00:00 2001 From: Lina Wolf <48202465+linawolf@users.noreply.github.com> Date: Thu, 4 Apr 2024 18:44:46 +0200 Subject: [PATCH] [TASK] Overhaul HMENU updated page (#1186) * [TASK] Overhaul HMENU updated page * Use confvals * Correct indentation Remove the larger part of the example as using this menu type is not recommended anymore. releases: main, 12.4, 11.5 * [TASK] Link to Custom Dataprocessor --- .../ContentObjects/Hmenu/Userfunction.rst | 194 +++--------------- .../Hmenu/ContentObjectsHmenuExampleMenu.png | Bin 4883 -> 0 bytes 2 files changed, 29 insertions(+), 165 deletions(-) delete mode 100644 Documentation/Images/ManualScreenshots/FrontendOutput/Hmenu/ContentObjectsHmenuExampleMenu.png diff --git a/Documentation/ContentObjects/Hmenu/Userfunction.rst b/Documentation/ContentObjects/Hmenu/Userfunction.rst index 82eed139d..a9dec1e6c 100644 --- a/Documentation/ContentObjects/Hmenu/Userfunction.rst +++ b/Documentation/ContentObjects/Hmenu/Userfunction.rst @@ -1,186 +1,50 @@ -.. include:: /Includes.rst.txt -.. index:: HMENU; special = userfunction -.. _hmenu-special-userfunction: +.. include:: /Includes.rst.txt +.. index:: HMENU; special = userfunction +.. _hmenu-special-userfunction: -======================= +================= Userfunction menu -======================= +================= -.. attention:: - It is still possible to create a menu with :typoscript:`special = userfunction` - for backward compatibility reasons. +.. attention:: + It is still possible to create a menu with :typoscript:`special = userfunction` + for backward compatibility reasons. - However we would advise you to write a customized MenuProcessor and style - the output with Fluid instead. + However we would advise you to write a :ref:`customized MenuProcessor ` + and style the output with Fluid instead. Calls a user function/method in class which should return an array with page records for the menu. -.. contents:: - :local: +.. contents:: + :local: + +.. _hmenu-special-userfunction-properties: Properties ========== -.. _hmenu-special-userfunction-userfunc: +.. _hmenu-special-userfunction-userfunc: special.userFunc ---------------- -.. ### BEGIN~OF~TABLE ### - -.. container:: table-row - - Property - special.userFunc - - Data type - string - - Description - Name of the function - - -.. ###### END~OF~TABLE ###### - -[tsref:(cObject).HMENU.special = userfunction] - -Example -======= - -.. _hmenu-special-userfunction-examples: - -Example: Creating hierarchical menus of custom links ----------------------------------------------------- - -By default the HMENU object is designed to create menus from pages in -TYPO3. Such pages are represented by their page-record contents. -Usually the "title" field is used for the title and the "uid" field is -used to create a link to that page in the menu. - -However the HMENU and sub-menu objects are so powerful that it would -be very useful to use these objects for creating menus of links which -do not relate to pages in TYPO3 by their ids. This could be a menu -reflecting a menu structure of a plugin where each link might link to -the same page id in TYPO3 but where the difference would be in some -parameter value. - -First, this listing creates a menu in three levels where the first two -are graphical items: - -.. code-block:: typoscript - :linenos: - - # ************************ - # CUSTOM MENU - # ************************ - lib.custommenu = HMENU - lib.custommenu { - special = userfunction - special.userFunc = Vendor\MyExtension\Userfuncs\CustomMenu->makeMenuArray - - 1 = TMENU - 1.wrap = - 1.NO = 1 - 1.NO { - wrapItemAndSub =
  • |
  • - } - - 2 = TMENU - 2.wrap = - 2.NO = 1 - 2.NO { - wrapItemAndSub =
  • |
  • - } - - 3 = TMENU - 3.wrap = - 3.NO = 1 - 3.NO { - wrapItemAndSub =
  • |
  • - } - } - -The menu looks like this on a web page: - -.. figure:: /Images/ManualScreenshots/FrontendOutput/Hmenu/ContentObjectsHmenuExampleMenu.png - :alt: Output of the example menu. - -The TypoScript code above generates this menu, but the items do not -link straight to pages as usual. This is because the *whole* menu is -generated from this array, which was returned from the function -"makeMenuArray" called in TypoScript line 5+6 : - -.. code-block:: php - :linenos: - - 'Contact', - '_OVERRIDE_HREF' => 'index.php?id=10', - '_SUB_MENU' => [ - [ - 'title' => 'Offices', - '_OVERRIDE_HREF' => 'index.php?id=11', - '_OVERRIDE_TARGET' => '_top', - 'ITEM_STATE' => 'ACT', - '_SUB_MENU' => [ - [ - 'title' => 'Copenhagen Office', - '_OVERRIDE_HREF' => 'index.php?id=11&officeId=cph', - ], - [ - 'title' => 'Paris Office', - '_OVERRIDE_HREF' => 'index.php?id=11&officeId=paris', - ], - [ - 'title' => 'New York Office', - '_OVERRIDE_HREF' => 'https://example.org', - '_OVERRIDE_TARGET' => '_blank', - ] - ] - ], - [ - 'title' => 'Form', - '_OVERRIDE_HREF' => 'index.php?id=10&cmd=showform', - ], - [ - 'title' => 'Thank you', - '_OVERRIDE_HREF' => 'index.php?id=10&cmd=thankyou', - ], - ], - ], - [ - 'title' => 'Products', - '_OVERRIDE_HREF' => 'index.php?id=14', - ] - ]; - } +.. confval:: special.userFunc + :name: hmenu-userfunction-special-userfunc + :type: string - } + Name of the user function -Notice how the array contains "fake" page-records which has *no* uid -field, only a "title" and "\_OVERRIDE\_HREF" as required and some -other fields as it fits. +.. _hmenu-special-userfunction-examples: -- The first level with items "Contact" and "Products" contains "title" - and "\_OVERRIDE\_HREF" fields, but "Contact" extends this by a - "\_SUB\_MENU" array which contains a similar array of items. +Example: Set a userFunc +~~~~~~~~~~~~~~~~~~~~~~~ -- The first item on the second level, "Offices", contains a field called - "\_OVERRIDE\_TARGET". Further the item has its state set to "ACT" - which means it will render as an "active" item (you will have to - calculate such stuff manually when you are not rendering a menu of - real pages!). Finally there is even another sub-level of menu items. +.. code-block:: typoscript + :caption: This is still possible for backward compability reasons but not recommended: + lib.custommenu = HMENU + lib.custommenu { + special = userfunction + special.userFunc = MyVendor\MyExtension\Userfuncs\CustomMenu->makeMenuArray + } diff --git a/Documentation/Images/ManualScreenshots/FrontendOutput/Hmenu/ContentObjectsHmenuExampleMenu.png b/Documentation/Images/ManualScreenshots/FrontendOutput/Hmenu/ContentObjectsHmenuExampleMenu.png deleted file mode 100644 index d9f9c5d54555b8e3586dc15cbdad6212647f9cf3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4883 zcmZ8l1yodB+Xd-v5s4ur1OaJ=81R)CLKu)7It78D8>9rJ8zhHDk&+bYZfO|GAym3# zfT6#6<6qzVe|N2W?^^fV^PF|g-Fu(CZxlpBnT+@$F%}jUnF?4z8*?wloF549VXkX* zQ%+b|)Qc(#&vblp_H#)fy0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