Skip to content

Commit

Permalink
[TASK] Document Footer menu (#339)
Browse files Browse the repository at this point in the history
* [TASK] Document Footer menu

Releases: main, 13.4

* Update Documentation/Menu/MetaMenu.rst

Co-authored-by: Stefan Frömken <[email protected]>

* Update Documentation/Menu/MetaMenu.rst

Co-authored-by: Stefan Frömken <[email protected]>

---------

Co-authored-by: Stefan Frömken <[email protected]>
  • Loading branch information
linawolf and froemken authored Jan 28, 2025
1 parent a947071 commit 88e6312
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 2 deletions.
1 change: 1 addition & 0 deletions Documentation/Menu/Breadcrumb.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
:navigation-title: Breadcrumb

.. include:: /Includes.rst.txt

.. _breadcrumb:
Expand Down
7 changes: 5 additions & 2 deletions Documentation/Menu/Index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
:navigation-title: Menus
.. include:: /Includes.rst.txt

.. include:: /Includes.rst.txt

.. _menu:

Expand Down Expand Up @@ -156,4 +157,6 @@ to demonstrate different menu types:
* A breadcrumb configured in
:file:`packages/my_site_package/Configuration/Sets/SitePackage/TypoScript/Navigation/breadcrumb.typoscript`
and rendered in :file:`packages/my_site_package/Resources/Private/PageView/Partials/Navigation/Breadcrumb.html`.
* A footer menu (example is still missing).
* A footer menu consisting of pages within a selected folder configured in
:file:`packages/my_site_package/Configuration/Sets/SitePackage/TypoScript/Navigation/footerMenu.typoscript`
and rendered in :file:`packages/my_site_package/Resources/Private/PageView/Partials/Navigation/FooterMenu.html`.
111 changes: 111 additions & 0 deletions Documentation/Menu/MetaMenu.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
:navigation-title: Breadcrumb

.. include:: /Includes.rst.txt

.. _meta-menu:

================================
Meta menu / Footer menu in TYPO3
================================

A meta menu - often but not always displayed in the footer of a website -
displays only selected pages like "Imprint", "Contact", "Data Privacy", ...

If you use a `Generated site package <https://docs.typo3.org/permalink/t3sitepackage:minimal-design>`_
it already contains a meta menu in the footer of the page.

To display a breadcrumb the `menu data processor <https://docs.typo3.org/permalink/t3tsref:menuprocessor>`_
can be used with the special type `List <https://docs.typo3.org/permalink/t3tsref:hmenu-special-list>`_
or `Directory <https://docs.typo3.org/permalink/t3tsref:hmenu-special-directory>`_.

The special menu type "List" allows you to specify a list of UIDs of pages that
should be displayed in the meta menu. The special menu type "Directory" allows
you to specify a folder or page of which all subpages should be displayed in
the menu. We take the second approach here.

.. _meta-menu-typoscript:

Menu of subpages TypoScript - the data processor
================================================

.. literalinclude:: /CodeSnippets/my_site_package/Configuration/Sets/SitePackage/TypoScript/Navigation/footerMenu.typoscript
:caption: packages/my_site_package/Configuration/Sets/SitePackage/TypoScript/Navigation/footerMenu.typoscript
:linenos:
:emphasize-lines: 7-8

Line 4: Each data processor must have a unique id. We used 10 for the
`page-content data processor <https://docs.typo3.org/permalink/t3sitepackage:page-content-data-processor>`_
and 20 for the :ref:`Main menu <main-menu-creation>` and 30 for the
`Breadcrumb <https://docs.typo3.org/permalink/t3sitepackage:breadcrumb>`_
therefore we now use 40.

Line 6: The values processed by the data processor should be stored in variable
`footerMenu`.

Line 7: We configure the menu to use the special type
`Directory <https://docs.typo3.org/permalink/t3tsref:hmenu-special-directory>`_.

Line 8: The folder which contains the pages to be displayed in the footer menu
can be configured via site settings. You can find the definition of this setting
in file :file:`packages/my_site_package/Configuration/Sets/SitePackage/settings.definitions.yaml`.

.. _meta-menu-fluid:

Menu of subpages - Fluid template
=================================

The special type `directory` delivers the items of the meta menu as an array.
Therefore we can use the `For ViewHelper <f:for> <https://docs.typo3.org/permalink/t3viewhelper:typo3fluid-fluid-for>`_
to loop through these elements:

.. literalinclude:: /CodeSnippets/my_site_package/Resources/Private/PageView/Partials/Navigation/FooterMenu.html
:caption: packages/my_site_package/Resources/Private/PageView/Partials/Navigation/FooterMenu.html
:linenos:

The menu items can be displayed just as we have done in the
`Fluid partial of the main menu <https://docs.typo3.org/permalink/t3sitepackage:fluid-implement-main-menu>`_.

As we do not need to highlight active pages in the footer menu we omit those
conditions.

.. _meta-menu-list:

Switching to the menu type list
===============================

If it is more feasible for your project to list all pages that should be listed
in the meta menu, you can switch to using the special menu type "List" by
changing the TypoScript:

.. code-block:: diff
:caption: packages/my_site_package/Configuration/Sets/SitePackage/settings.definitions.yaml (diff)
40 = menu
40 {
as = footerMenu
- special = directory
+ special = list
special.value = {$MySitePackage.footerMenuRoot}
}
You can now change the setting to accept a comma separated list of integers
and then list all pages that should be displayed in the meta menu. For example:

.. code-block:: diff
:caption: packages/my_site_package/Configuration/Sets/SitePackage/TypoScript/Navigation/footerMenu.typoscript (diff)
MySitePackage.footerMenuRoot:
label: 'Footer menu root uid'
- description: 'The subpages of this page are displayed in the footer'
+ description: 'These pages are displayed in the footer'
category: MySitePackage.menus
- type: int
+ type: stringlist
- default: 2
+ default:
+ - 5
+ - 4
+ - 3
We are using the type :ref:`stringlist <t3coreapi:confval-site-setting-type-stringlist>`
- as of writing these lines - there is no integer list type in the settings yet.

0 comments on commit 88e6312

Please sign in to comment.