|
1 | 1 | .. include:: /Includes.rst.txt |
2 | | - |
3 | 2 | .. _guide-menu: |
4 | 3 |
|
5 | | -============= |
6 | | -Create a menu |
7 | | -============= |
| 4 | +============================= |
| 5 | +Create a menu with TypoScript |
| 6 | +============================= |
8 | 7 |
|
9 | 8 | Until now, we learned how the page *content* is rendered; however, the |
10 | 9 | page *navigation* is missing. |
11 | 10 |
|
12 | | -TYPO3 CMS offers a special menu object called |
13 | | -:ref:`HMENU <cobj-hmenu>` ("H" stands for hierarchical) to easily build |
14 | | -different kinds of menus. |
15 | | - |
16 | | -We want our menu to be built like a nested list: |
17 | | - |
18 | | -.. literalinclude:: _menu.html |
19 | | - |
20 | | -It is customary to declare new objects as sub-properties of the |
21 | | -`lib` top-level object. We can give it any name that hasn't |
22 | | -been assigned yet: |
23 | | - |
24 | | -.. literalinclude:: _lib.textmenu.typoscript |
25 | | - |
26 | | -The :ref:`HMENU <cobj-hmenu>` object allows us to create a diversity of menus. |
27 | | -The main properties are numbers and correspond to the menu level. |
| 11 | +TYPO3 provides a special data processor, the :ref:`menu data processor <MenuProcessor>` |
| 12 | +to pass data to render a menu to the Fluid template. |
28 | 13 |
|
29 | | -The :ref:`TMENU <tmenu>` object renders a menu level as |
30 | | -text. A different |
31 | | -rendering can be chosen for each menu level. |
| 14 | +Configure the data processor in TypoScript: |
32 | 15 |
|
33 | | -On every menu level, we can configure various states for the single |
34 | | -menu items – see :ref:`menu items <menu-common-properties>`, |
35 | | -e.g. `NO` for "normal", `ACT` for "pages in the root line" |
36 | | -(i.e. the current page, its parent, grandparent, and so forth) or |
37 | | -`CUR` for "the current page". |
| 16 | +.. literalinclude:: _menu.typoscript |
| 17 | + :caption: TypoScript Setup |
38 | 18 |
|
39 | | -.. important:: |
| 19 | +And render the menu in your Fluid template. You need at least a |
| 20 | +:ref:`Minimal site package (see site package tutorial) <t3sitepackage:minimal-design>` |
| 21 | +to keep your templates in its private resources folder, for example |
| 22 | +:path:`/packages/site_package/Resources/Private/Templates`: |
40 | 23 |
|
41 | | - Except for the normal state (`NO`), other states have to be activated |
42 | | - before they get displayed (i.e. `ACT = 1`). |
| 24 | +.. literalinclude:: _MenuTemplate.html |
| 25 | + :caption: /packages/site_package/Resources/Private/Templates/Pages/Default.html |
43 | 26 |
|
44 | | -Now that our menu is defined, we can use it with: |
| 27 | +Find more examples on how to configure and render menus with TypoScript and |
| 28 | +Fluid in chapter |
| 29 | +:ref:`Main menu of the Site Package Tutorial <t3sitepackage:main-menu-creation>`. |
45 | 30 |
|
46 | | -.. code-block:: typoscript |
| 31 | +You can find more examples on how to output menus of different styles, including |
| 32 | +multi-level menus, breadcrumbs, language menus, and sitemaps in the chapter |
| 33 | +about the :ref:`menu data processor <MenuProcessor>`. |
47 | 34 |
|
48 | | - page.5 < lib.textmenu |
| 35 | +.. note:: |
| 36 | + Before data processors were introduced it was common to use the TypoScript |
| 37 | + object :ref:`HMENU <t3tsref:cobj-hmenu>` to render a menu. It is still |
| 38 | + possible doing so and you might see it in older examples. |
0 commit comments