Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including CSS File in TYPO3 Backend?

I am trying to include my cascading style sheet into my TYPO3 extension. I created the extension with "kickstarter". This is the way I tried to include it:

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

I added that line at the end of the main() method. So what am I doing wrong? The path including the file does definately exist.

Thank you.

like image 870
oopbase Avatar asked Dec 10 '22 10:12

oopbase


2 Answers

And if You would like to include CSS file in other module than Yours, without to modify it, You could use $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";';
}
like image 199
Fedir RYKHTIK Avatar answered Jan 31 '23 05:01

Fedir RYKHTIK


Ok, I could finally solve the problem.

When adding the code right after instancing 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');
like image 38
oopbase Avatar answered Jan 31 '23 06:01

oopbase