.. include:: /Includes.rst.txt .. _menu: .. _create-a-menu: Create a menu ------------- Until now, we learned how the page *content* is rendered; however, the page *navigation* is missing. TYPO3 CMS offers a special menu object called :ref:`HMENU ` ("H" stands for hierarchical) to easily build different kinds of menus. We want our menu to be built like a nested list: .. code-block:: html It is customary to declare new objects as sup-properties of the :code:`lib` top-level object. We can give it any name that hasn't been assigned yet. .. code-block:: typoscript lib.textmenu = HMENU lib.textmenu { # We define the first level as text menu. 1 = TMENU # We define the normal state ("NO"). 1.NO = 1 1.NO.allWrap =
  • |
  • # We define the active state ("ACT"). 1.ACT = 1 1.ACT.wrapItemAndSub =
  • |
  • # Wrap the whole first level. 1.wrap = # The second and third level should be configured exactly # the same way. # In between the curly brackets, objects can be copied. # With the dot "." we define that the object can be found # in the brackets. # With 2.wrap and 3.wrap we overwrite the wrap, which was # copied from 1.wrap. 2 < .1 2.wrap = 3 < .1 3.wrap = } The :ref:`HMENU ` object allows us to create a diversity of menus. The main properties are numbers and correspond to the menu level. The :ref:`TMENU ` object renders a menu level as text. There also exists a :ref:`GMENU ` object which renders a menu level using images generated on the fly. A different rendering can be chosen for each menu level. On every menu level, we can configure various states for the single menu items – see :ref:`menu items `, e.g. :code:`NO` for "normal", :code:`ACT` for "pages in the root line" (i.e. the current page, its parent, grandparent, and so forth) or :code:`CUR` for "the current page". .. important:: Except for the normal state (:code:`NO`), other states have to be activated before they get displayed (i.e. :code:`ACT = 1`). Now that our menu is defined, we can use with: .. code-block:: typoscript page.5 < lib.textmenu