I'm trying to load a component custom css file, placed in the frontend media folder in the media/mycomponent/css folder, to load into the backend after the backend template.css file (Isis) is loaded (in the head tag of every page). Is this possible? I've tried some options but so far no success.
2 Answers
In the view of your component just add the CSS declaration as you normally would on the front end. Should work with no issues.
JFactory::getDocument()->addStyleSheet(JPATH_SITE . '/media/mycomponent/css/STYLE.css');
This should pull from the front end. You may be able to substitue JPATH_ROOT as well.
-
Thanks for reply, this works indeed in a view of a component. But in my case it is not the solution. I should be more specific what I want: in the options view of the config component (url: ../administrator/index.php?option=com_config&view=component&component=com_mycomponent), I want to load a specific lay-out. Would this be possible from within the component without 'hacking' the core of Joomla?– FrankyCommented May 11, 2017 at 3:56
If you want to add a a custom html into component configuration popup you would have to create your own field type. That way you can manage the layout but still keep your component inside a framework flow and your configuration will be saved. All the custom stylesheets and scripts can be included same as in view templates.