Including CSS file in TYPO3 Backend?

I am trying to include my cascading style sheet in the TYPO3 extension. I created the extension using "kickstarter". So I tried to enable it:

$this->doc->getPageRenderer()->addCssFile(t3lib_extMgm::extRelPath('myExt') . 'res/css/my_stylesheet.css'); 

I added this line at the end of the main() method. So what am I doing wrong? The path containing the file definitely exists.

Thanks.

+4
source share
3 answers

Well, I could finally solve the problem.

When adding code immediately after starting the "doc" object, everything works fine.

 $this->doc = t3lib_div::makeInstance('mediumDoc'); $this->doc->getPageRenderer()->addCssFile(t3lib_extMgm::extRelPath('myExt') . 'res/css/my_stylesheet.css'); 
+6
source

And if you want to include the CSS file in a module other than yours, without changing it, you can use the $ TBE_STYLES array.

ext_tables.php:

 // Custom CSS include if (TYPO3_MODE=="BE") { $TBE_STYLES['inDocStyles_TBEstyle'] .= '@import "/typo3conf/ext/your_ext/res/css/your.css";'; } 
+7
source

White task will work for version TYPO3 8.7.X

Step-1 Add the following lines to the ext_tables.php file

 $GLOBALS['TBE_STYLES']['skins'][$_EXTKEY]['name'] = $_EXTKEY; $GLOBALS['TBE_STYLES']['skins'][$_EXTKEY]['stylesheetDirectories']['css'] = 'EXT:'.$_EXTKEY.'/stylesheets/visual/'; 

Step-2: Define a css file with any name on the specified path (in our case its ' stylesheets / visual / ' inside the extension)

0
source

Source: https://habr.com/ru/post/1342270/


All Articles