Search code examples
typo3extbasetypo3-9.x

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


Is there a way to work with dataProcessing / MenuProcessor within an Extbase Frontend Plugin in TYPO3 9?

I want to build a page rootline within a plugin. I know how to make it in page context or in a tt-content element but can I get it in a plugin too?

I tried the following in my plugin setup, but this does not work:

plugin.tx_extensions_show {
    view {
        ...
        dataProcessing {
            10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
            10 {
                special = rootline
                special.range = 1|-1
                includeNotInMenu = 1
                as = rootline
            }
        }
    }
}

Solution

  • Inside your plugin code you can fetch the rootline in an array:

    // ($MP and $this->context are optional)
    $rootline = GeneralUtility::makeInstance(RootlineUtility::class, $uid, $MP, $this->context);
    $rootlinePages = $rootline->get();
    

    Now you can pass $rootlinePages on to your FLUID template.

    Hth.