addStyleDeclaration() not working in backend - why?

For Joomla! 3.x Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Post Reply
gba
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 105
Joined: Tue Jun 03, 2014 3:37 pm

addStyleDeclaration() not working in backend - why?

Post by gba » Thu Jan 14, 2021 3:18 pm

Hi all!

In the install.php file of my component I want to add CSS styles for HTML code I am displaying 'onInstall'.
I tried:

Code: Select all

$doc = JFactory::getDocument();
$doc->addStyleDeclaration('...');
I tried also this (is this better btw.?):

Code: Select all

use Joomla\CMS\Factory;
$doc = Factory::getDocument();
$doc->addStyleDeclaration('...');
No style declaration is being added to the <head>, though.
Anyone any idea what is wrong?

Thank you very much in advance for any useful hint!

Kind regards,
Gerald
Last edited by toivo on Thu Jan 14, 2021 3:29 pm, edited 1 time in total.
Reason: mod note: moved from 3.x Extensions

gba
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 105
Joined: Tue Jun 03, 2014 3:37 pm

Re: addStyleDeclaration() not working in backend - why?

Post by gba » Fri Jan 22, 2021 2:42 pm

Hi!

Is that question so trivial, that noone is answering? ;)
Or is it so difficult/tricky? :(

Kind regards,
Gerald

gba
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 105
Joined: Tue Jun 03, 2014 3:37 pm

Re: addStyleDeclaration() not working in backend - why?

Post by gba » Thu Apr 08, 2021 1:21 pm

???

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2016
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: addStyleDeclaration() not working in backend - why?

Post by SharkyKZ » Thu Apr 08, 2021 1:28 pm

What do you mean "onInstall"?

gba
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 105
Joined: Tue Jun 03, 2014 3:37 pm

Re: addStyleDeclaration() not working in backend - why?

Post by gba » Mon Apr 12, 2021 2:52 pm

Hi!

Thank you for answering.
I mean the

Code: Select all

public function install() { ... }
in the file install.php.
(see https://docs.joomla.org/J3.x:Developing ... cript_file)

Why is no style declaration being added to the <head> of installation page of my extension in the backend?

Kind regards,
Gerald

gba
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 105
Joined: Tue Jun 03, 2014 3:37 pm

Re: addStyleDeclaration() not working in backend - why?

Post by gba » Thu Oct 14, 2021 9:55 am

Anyone any idea?

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2016
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: addStyleDeclaration() not working in backend - why?

Post by SharkyKZ » Thu Oct 14, 2021 11:04 am

It doesn't work because install happens on one request and extension description is shown on another.

gba
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 105
Joined: Tue Jun 03, 2014 3:37 pm

Re: addStyleDeclaration() not working in backend - why?

Post by gba » Thu Oct 14, 2021 6:35 pm

What do you mean?
And how can I then add style declaration to the head of the installation page?


Post Reply

Return to “Joomla! 3.x Coding”