TYPO3: Disable page tree of backend module in main module "Web"


Share it: facebookTwitter | LinkedIn

If you create your own backend module in TYPO3 and position it in the main module "Web", the page tree is displayed between the menu bar and the actual content of the module. To prevent this there is a setting navigationComponentId in the function call of the TYPO3 function ExtensionUtility::registerModule, which is normally located in the ext_tables.php file of the custom extension.

Example: Backend module without page tree in the main "Web" module

The following code shows an example of registering a backend module which is placed in the main "Web" module. In the ext_tables.php of the custom extension:

<?php
defined('TYPO3_MODE') || die('Access denied.');

call_user_func(
    function()
    {

        // Registration of the backend module
        \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
            'MyExt',	// Extension name
            'web',		// Module position
            'theme',	// Module name
            '',
            [
                \VENDOR\MyExt\Controller\ThemeController::class => 'dashboard'
            ],
            [
                'access' => 'admin',
                'icon' => 'EXT:myext/Resources/Public/Icons/eleganz.svg',
                'labels' => 'LLL:EXT:myext/Resources/Private/Language/locallang_mod.xlf',
				// Set to empty if you want no pagetree
                'navigationComponentId' => '',
				// Important: Do not inherit settings from parent module
                'inheritNavigationComponentFromMainModule' => false
            ]
        );

    }
);

What does the code do?

The option in line 22 disables the page tree by setting the path to the navigation component to an empty string.

The option in line 24 prevents the setting from being inherited from the parent module again. However, this only affects the main module Web, not the other main modules.

Show module in main module "Admin tools" with page tree

We've learned that the main web module displays the page tree by default, and the other modules do not. But what if the page tree should be displayed in the main module admin tools? You have to enable this explicitly by entering the classpath TYPO3/CMS/Backend/PageTree/PageTreeElement as value for navigationComponentId. See the following code in line 22.

<?php
defined('TYPO3_MODE') || die('Access denied.');

call_user_func(
    function()
    {

        // Registration of the backend module
        \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
            'MyExt',	// Extension name
            'tools',	// Module position
            'theme',	// Module name
            '',
            [
                \VENDOR\MyExt\Controller\ThemeController::class => 'dashboard'
            ],
            [
                'access' => 'admin',
                'icon' => 'EXT:myext/Resources/Public/Icons/eleganz.svg',
                'labels' => 'LLL:EXT:myext/Resources/Private/Language/locallang_mod.xlf',
				// Using the PageTreeElement-Class to activate the page tree
                'navigationComponentId' => 'TYPO3/CMS/Backend/PageTree/PageTreeElement'
            ]
        );

    }
);

Conclusion

Since the backend main module Web in TYPO3 displays the page tree by default, an additional parameter is necessary to disable the page tree for a custom module. Since all other main modules do not display a page tree, it must be enabled manually if it is to be displayed.

Finger pointing at you!

WE WANT YOU!

Your are a web design expert and you like writing articles?

JOIN US

cleverreach

Write comment

* These fields are required

Comments

No Comments


Share it: facebookTwitter | LinkedIn
100% anonymous web host