:navigation-title: Menus .. include:: /Includes.rst.txt .. _menu: ======================== Rendering menus in TYPO3 ======================== There are several strategies to display menus or other navigation elements like breadcrumbs and sitemaps in TYPO3. .. contents:: .. toctree:: :glob: :hidden: * .. _menu-content-element: Menus as content elements ========================= You can use a content element to display a menu. In the example data "Page 1" contains a menu of subpages and page "Sitemap" a sitemap content element. To adjust the templates of these content elements refer to chapter `Overriding the default templates of content elements `_. .. _menu-page-view: Menus within the page view ========================== A data processor (see also :ref:`dataProcessing `) can be used to provide the data for one or several menus. For menus usually the `menu data processor `_, which is provided by the TYPO3 Core, is used. .. tip:: Some extensions like :composer:`b13/menus` offer performant menus for large sites or like :composer:`georgringer/news` menus for special purposes. .. _main-menu-creation: .. _add-menu-processor: TypoScrip configuration of the main menu ======================================== We use TypoScript to configure these menus. The main menu is configured like this: .. literalinclude:: /CodeSnippets/my_site_package/Configuration/Sets/SitePackage/TypoScript/Navigation/menu.typoscript :caption: packages/my_site_package/Configuration/Sets/SitePackage/TypoScript/Navigation/menu.typoscript This menu defines that the variable with the default name `menu` should contain the information about the complete page tree of the current page. System folders like the "Footer menu" from your example data, special page types and pages excluded from the navigation are excluded. A complete reference of this menu can be found in the TypoScript Reference: `menu data processor `_. .. _fluid-implement-main-menu: Fluid partial of the main menu ============================== In :path:`packages/my_site_package/Resources/Private/PageView/Partials/Navigation/Menu.html` you can find the partial that renders the main menu. A menu usually contains several menu entries. We use the :ref:`t3viewhelper:typo3fluid-fluid-for` to iterate over all menu entries and render them in turn: .. literalinclude:: /CodeSnippets/my_site_package/Resources/Private/PageView/Partials/Navigation/Menu.html :caption: packages/my_site_package/Resources/Private/PageView/Partials/Navigation/Menu.html :linenos: In each loop the current menu item is stored in variable `{menuItem}`. You can use the :ref:`t3viewhelper:typo3-fluid-debug` to debug what kind of data the variable contains like this: .. code-block:: diff :caption: packages/my_site_package/Resources/Private/PageView/Partials/Navigation/Menu.html (changed for debug output)