typo3typoscript

How to use the MenuProcessor to render the rootline of a specific page?


Is there a simple way to use the TYPO3\CMS\Frontend\DataProcessing\MenuProcessor to render the rootline (breadcrumb) for a specific page instead of the current one?

Mixing special = rootline and special.value (like for special type directory) does not work:

dataProcessing {
  10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
  10 {
    special = rootline
    special.value = <PAGE-ID>
    as = breadcrumbs
  }
}

Using multiple definitions of MenuProcessor.

I expect to render the breadcrumb for a different page than the current requested.


Solution

  • Unfortunately it's not possible to achive this with special = rootline.

    But if you know the PageId of the page you want the rootline for, then you also know the rootline of that page. So you could use special = list to create the menu. The only problem is, when the rootline of the page changes you need to adjust the menu.
    https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/ContentObjects/Hmenu/List.html

    Another way to achive what you want, would be to create a menu with a user function. (special = userfunction)
    https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/ContentObjects/Hmenu/Userfunction.html

    In the userfunction you could then use the RootlineUtility of the core to get the rootline of your page. Here is an example for TYPO3 9:

    How can I get a rootline / breadcrumb within an Extbase Frontent Plugin in TYPO3

    Maybe you should check the RootlineUtility class, if the implementation still works like this.
    https://github.com/TYPO3-CMS/core/blob/3c7eb849fca0033d85c8cb83581e3ae06d17a98f/Classes/Utility/RootlineUtility.php#L65