|
| 1 | +:navigation-title: Breadcrumb |
| 2 | +.. include:: /Includes.rst.txt |
| 3 | + |
| 4 | +.. _breadcrumb: |
| 5 | + |
| 6 | +========================================= |
| 7 | +Breadcrumb / rootline navigation in TYPO3 |
| 8 | +========================================= |
| 9 | + |
| 10 | +If you use a `Generated site package <https://docs.typo3.org/permalink/t3sitepackage:minimal-design>`_ |
| 11 | +it already contains a breadcrumb navigation on the subpages. |
| 12 | + |
| 13 | +To display a breadcrumb the `menu data processor <https://docs.typo3.org/permalink/t3tsref:menuprocessor>`_ |
| 14 | +can be used with the special type `Rootline <https://docs.typo3.org/permalink/t3tsref:hmenu-special-rootline>`_. |
| 15 | + |
| 16 | +.. _breadcrumb-typoscript: |
| 17 | + |
| 18 | +Breadcrumb TypoScript - the data processor |
| 19 | +========================================== |
| 20 | + |
| 21 | +.. literalinclude:: /CodeSnippets/my_site_package/Configuration/Sets/SitePackage/TypoScript/Navigation/breadcrumb.typoscript |
| 22 | + :caption: packages/my_site_package/Configuration/Sets/SitePackage/TypoScript/Navigation/breadcrumb.typoscript |
| 23 | + :linenos: |
| 24 | + :emphasize-lines: 6-8 |
| 25 | + |
| 26 | +Line 4: Each data processor must have a unique id. We used 10 for the |
| 27 | +`page-content data processor <https://docs.typo3.org/permalink/t3sitepackage:page-content-data-processor>`_ |
| 28 | +and 20 for the :ref:`Main menu <main-menu-creation>` therefore we now use 30. |
| 29 | + |
| 30 | +Line 6: We configure the menu to use the special type |
| 31 | +`Rootline <https://docs.typo3.org/permalink/t3tsref:hmenu-special-rootline>`_. |
| 32 | + |
| 33 | +Line 7: We use the property :ref:`special.range <t3tsref:confval-hmenu-rootline-special-range>` |
| 34 | +to define that the breadcrumb should start at the root level (0) of the site and |
| 35 | +include the level of the current page (-1). |
| 36 | + |
| 37 | +Line 8: As the default variable of the menu data processor `menu` is already in |
| 38 | +use for the main menu, we rename the variable to be used for the breadcrumb to |
| 39 | +`breadcrumb`. |
| 40 | + |
| 41 | +.. _breadcrumb-fluid: |
| 42 | + |
| 43 | +Breadcrumb navigation Fluid template |
| 44 | +==================================== |
| 45 | + |
| 46 | +The special type `breadcrumb` delivers the items of the rootline as an array. |
| 47 | +Therefore we can use the `For ViewHelper <f:for> <https://docs.typo3.org/permalink/t3viewhelper:typo3fluid-fluid-for>`_ |
| 48 | +to loop through these elements: |
| 49 | + |
| 50 | +.. literalinclude:: /CodeSnippets/my_site_package/Resources/Private/PageView/Partials/Navigation/Breadcrumb.html |
| 51 | + :caption: packages/my_site_package/Resources/Private/PageView/Partials/Navigation/Breadcrumb.html |
| 52 | + :linenos: |
| 53 | + |
| 54 | + |
| 55 | +Line 1, 5: The data of the breadcrumb navigation can be found in variable |
| 56 | +`{breadcrumb}`. We defined this in line 8 of the :ref:`TypoScript <breadcrumb-typoscript>`. |
| 57 | + |
| 58 | +Line 6: As all items in the breadcrumb navigation are in the rootline of the |
| 59 | +current page all are marked as `active`. We therefore check if the page of the |
| 60 | +entry to be displayed is the `current` page. |
0 commit comments