Is it possible to pull in a CSS file within a Wiki ?

LabKey Support Forum
Is it possible to pull in a CSS file within a Wiki ? Leo Dashevskiy  2017-02-23 16:18
Status: Closed
 
This works when placed in an HTML file of a file-based module, in my case, the "footer", which might not be regular module, I'm not sure, but not when placed into a UI based wiki:

<link rel="stylesheet" href="<%=contextPath%>/ISCore/Common/ISCore.css">

I do not see the <link> tag in the source code of the rendered wiki.

Thanks.
-Leo
 
 
Jon (LabKey DevOps) responded:  2017-02-23 21:59
Hi Leo,

I don't believe you can apply CSS within a wiki via a CSS file. The CSS will only render if the CSS file itself is used under the Site's Look and Feel settings under the Admin Console or under the Project Settings.

You can however apply specific CSS code within the wiki markup as explained here:

https://www.labkey.org/home/Documentation/wiki-page.view?name=moreWikiSyntax

Regards,

Jon
 
Leo Dashevskiy responded:  2017-02-27 12:44
Thanks, Jon.

Yes, I'm aware of the Look and Feel settings, of course, and also already read up on CSS code within the wiki markup.

Unfortunately, that's not what would be preferable to us.


An alternative approach to Look and Feel settings is to stick the loading of the CSS file into the footer "web part" and that's what seems to work, but it's not ideal because it loads it each time on each page, but it'd be nice to only load it, where the wiki is present...
 
Jon (LabKey DevOps) responded:  2017-02-27 13:23
Hi Leo,

Upon further digging, how about working with our Javascript API?

https://www.labkey.org/download/clientapi_docs/javascript-api/symbols/LABKEY.html#.requiresCss

If you throw in:

             <script type="text/javascript">
                LABKEY.requiresCss("myModule/myFile.css");
             </script>

That would trigger the specific CSS file to work.

Regards,

Jon
 
Leo Dashevskiy responded:  2017-02-28 13:11
Yup, great suggestion, Jon! Works like a charm!

I have totally forgotten about this API, haven't used it for ages, ever since you guys introduces the XML based dependencies for modules.

Thanks.
-Leo