I'm trying to insert inline css in a module and it's not working.
In one of my modules php files i have the following:
$document = Factory::getDocument();
// Add styles
$style = 'body {'
. 'background: black;'
. 'color: rgb(0,111,51);'
. '}';
$document->addStyleDeclaration($style);
But the whole thing is just doing nothing. I googled and found some tutorials but even when I copy their solution it's still doing nothing. Am I missing something or is this deprecated or different in joomla 4?
I would really appreciate some help. Thank you all in advance.
Edit: I tried it in multiple files and different modules but it just does nothing. Same With inline javascript and even with "$document->addStyleSheet
" and "$document->addScript
".
2nd Edit: I tried it in my templates index.php and its also not working there. So Either its a general problem or I'm doing something wrong.
But it recognizes the "$document->addStyleDeclaration($style);
" because when I forgot to define the document it told me that I cannot call addStyleDeclaration on an empty.