Feature #102261


Allow <f:be.pageRenderer> to unregister CSS files

Added by Garvin Hicking 9 months ago. Updated 9 months ago.

Should have
Backend User Interface
Target version:
Start date:
Due date:
% Done:


Estimated time:
PHP Version:
Sprint Focus:


Backend Module authors may want to deliver a fully customized
backend without the CSS framework of TYPO3.

Currently the pageRenderer is only able to register
additional CSS files for output, but the access to
the internal $cssFiles property is gated and no
event or get/setter allows to access it.

This patch adds the ability to both retrieve the
current list of $cssFiles and also a removeCssFile()

The ViewHelper is enhanced to allow access to these
methods, because when Extbase actions are executed,
accessing the PageRenderer singleton instance does
not yet have the internal stylesheets assigned.

A modules Fluid template could then do this:

            0: '@typo3/backend/global-event-handler.js',
            1: '@typo3/belog/backend-log.js'
            0: 'backend.css'

The array passed to removeCssFiles can contain
any string to match against the registered files,
so whole paths or specific files can be removed,
no matter if EXT:xxx syntax or a absolute file
(like for backend.css) is used.

(The Fluid viewhelper will also work for Backend modules
outside Extbase context.)

Actions #1

Updated by Gerrit Code Review 9 months ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at

Actions #2

Updated by Garvin Hicking 9 months ago

Turns out there IS an event that can be utilized, making the whole issue obsolete. Documented here, in case anyone ever wants to do that (HINT: Use your time to convert this hook to a PSR-14 event instead!).

So this hook is doing the magic:


It is executed as a last step within the PageRenderer class, passing all rendered parts of a page to the event.

So you can provide an extension that does the following.

Register the hook, in ext_localconf.php

        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-postProcess'][] =
            \YourVendor\YourExtension\Hooks\PostRenderHook::class . '->postProcessKillBackendCSS';

Create a hook class in Classes/Hooks/PostRenderHook.php

namespace YourVendor\YourExtension\Hooks;

class PostRenderHook
    public function postProcessKillBackendCSS(&$params, $object) {
        if (isset($GLOBALS['MY_EXTENSION']['removeBackendCss'])) {
            $params['cssFiles'] =
                    '@<link rel="stylesheet" href="[^"]+backend.css[^>]+>@imsU',
                    '<!-- removed TYPO3 Backend via popular demand -->',

            // You could do other hacks here as well, i.e. operate on $params['bodyContent']

Adjust your backend Controller, i.e. in a global initializeAction method:

$GLOBALS['MY_EXTENSION']['removeBackendCss'] = true;

The last step is important to instruct the hook that you only want to remove the backend CSS on your specific backend module. Else, you'd kill the backend.css file in EVERY backend module.

Abusing a global variable for this is the easiest approach, but a bit dirty. You might create a singleton object at that place which you later query, if you want to solve it "properly". Or you might let the hook introspect the body of the rendered page and get triggered by specific classes or whatnot.

Actions #3

Updated by Christian Kuhn 9 months ago

  • Status changed from Under Review to Closed

Thanks for documenting a solution!


Also available in: Atom PDF