Skip to content

Commit 487582a

Browse files
committed
[TASK] Adjust menu chapter for site package builder
Releases: main, 13.4
1 parent c653558 commit 487582a

File tree

2 files changed

+62
-38
lines changed

2 files changed

+62
-38
lines changed

Documentation/Index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ https://github.com/TYPO3-Documentation/site_package
136136
Assets/Index
137137
FluidTemplates/Index
138138
ContentMapping/Index
139-
MainMenuCreation/Index
139+
Menu/Index
140140
SiteSets/Index
141141
ContentElementRendering/Index
142142
ContentBlocks/Index
Lines changed: 61 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,70 @@
1+
:navigation-title: Menus
12
.. include:: /Includes.rst.txt
2-
.. _main-menu-creation:
33

4-
=========
5-
Main menu
6-
=========
4+
.. _menu:
75

8-
To display a main menu in our frontend output we need to provide the according
9-
data and define the view by providing templates for it.
6+
========================
7+
Rendering menus in TYPO3
8+
========================
109

11-
A data processor (see :ref:`dataProcessing <t3tsref:dataProcessing>`) can be
12-
used to provide the data for the menu to the template and a Fluid template
13-
partial do define the view of the menu.
10+
There are several strategies to display menus or other navigation elements like
11+
breadcrumbs and sitemaps in TYPO3.
1412

1513
.. contents::
1614

17-
.. _add-menu-processor:
15+
.. _menu-content-element:
16+
17+
Menus as content elements
18+
=========================
19+
20+
You can use a content element to display a menu. In the example data "Page 1"
21+
contains a menu of subpages and page "Sitemap" a sitemap content element.
22+
23+
To adjust the templates of these content elements refer to chapter
24+
`Overriding the default templates of content elements <https://docs.typo3.org/permalink/t3sitepackage:content-element-rendering>`_.
25+
26+
.. _menu-page-view:
27+
28+
Menus within the page view
29+
==========================
30+
31+
A data processor (see also :ref:`dataProcessing <t3tsref:dataProcessing>`) can be
32+
used to provide the data for one or several menus.
1833

19-
Use the data processor `menu`
20-
=============================
34+
For menus usually the `menu data processor <https://docs.typo3.org/permalink/t3tsref:menuprocessor>`_,
35+
which is provided by the TYPO3 Core, is used.
2136

22-
The :ref:`data processor 'menu' <t3tsref:MenuProcessor>` can be configured to
23-
provide the data of all pages in your current site to your page template.
37+
.. tip::
38+
Some extensions like :composer:`b13/menus` offer performant menus for
39+
large sites or like :composer:`georgringer/news` menus for special purposes.
2440

25-
We save the TypoScript configuration for the menu into file
26-
:file:`Configuration/Set/SitePackage/TypoScript/Navigation/menu.typoscript`:
41+
.. _main-menu-creation:
42+
.. _add-menu-processor:
43+
44+
TypoScrip configuration of the main menu
45+
========================================
46+
47+
We use TypoScript to configure these menus. The main menu is configured like this:
2748

2849
.. literalinclude:: /CodeSnippets/my_site_package/Configuration/Sets/SitePackage/TypoScript/Navigation/menu.typoscript
2950
:caption: packages/my_site_package/Configuration/Sets/SitePackage/TypoScript/Navigation/menu.typoscript
3051

31-
.. _fluid-implement-main-menu:
52+
This menu defines that the variable with the default name `menu` should contain
53+
the information about the complete page tree of the current page.
54+
55+
System folders like the "Footer menu" from your example data, special page types
56+
and pages excluded from the navigation are excluded.
3257

33-
Update the Fluid partial for the menu
34-
=====================================
58+
A complete reference of this menu can be found in the TypoScript Reference:
59+
`menu data processor <https://docs.typo3.org/permalink/t3tsref:menuprocessor>`_.
3560

36-
Until now we had static HTML in the file
37-
:file:`Resources/Private/PageView/Partials/Navigation/Menu.html`.
61+
.. _fluid-implement-main-menu:
3862

39-
We created that file in section :ref:`create_partial_header`.
63+
Fluid partial of the main menu
64+
==============================
4065

41-
Replace the static HTMl with Fluid:
66+
In :path:`packages/my_site_package/Resources/Private/PageView/Partials/Navigation/Menu.html`
67+
you can find the partial that renders the main menu.
4268

4369
A menu usually contains several menu entries. We use the
4470
:ref:`t3viewhelper:typo3fluid-fluid-for` to iterate over all menu entries
@@ -101,29 +127,27 @@ displayed in the :ref:`Fluid inline notation <t3coreapi:fluid-inline-notation>`.
101127
Preview the page and use the menu
102128
=================================
103129

104-
The menu in the page should now function and allow you to navigate from page to
105-
page.
130+
Whenever you change TypoScript files or Fluid templates, flush all caches:
106131

107-
Delete the frontend caches and preview the changes:
132+
.. code-block:: bash
108133
109-
When previewing the site as it stands now, we can verify if everything is
110-
working as expected and if the menu is generated. Go to **WEB → View** and
111-
check, if the menu reflects the pages you created in the backend. Add one or
112-
two additional pages to the page tree and check to see if they appear in the preview.
134+
ddev typo3 cache:flush
113135
114136
.. figure:: /Images/MainMenuCreation/CheckMainMenu.png
115137
:alt: Checking from the backend if the menu is generated as expected.
116138
:class: with-shadow
117139

118140
Checking from the backend if the menu is generated as expected.
119141

120-
If the menu does not change, you possibly need to flush the frontend caches,
121-
then reload the preview.
142+
.. _menu-types:
122143

123-
.. figure:: /Images/AutomaticScreenshots/FlushFrontendCaches.png
124-
:class: with-shadow
144+
Different menu types
145+
====================
125146

126-
Flush the frontend cache after changing template files
147+
We use the `menu data processor <https://docs.typo3.org/permalink/t3tsref:menuprocessor>`_
148+
to demonstrate different menu types:
127149

128-
The preview in the screenshot above shows the menu with three page links: "Page
129-
1", "Page 2" and "Page 3".
150+
* A breadcrumb configured in
151+
:file:`packages/my_site_package/Configuration/Sets/SitePackage/TypoScript/Navigation/breadcrumb.typoscript`
152+
and rendered in :file:`packages/my_site_package/Resources/Private/PageView/Partials/Navigation/Breadcrumb.html`.
153+
* A footer menu (example is still missing).

0 commit comments

Comments
 (0)