I you "only" want to inject a stylesheet into the backoffice, then you can do that by creating a package.manifest file in a folder inside app_pluigns folder (e.g app_plugins/myfolder/package.manifest)
I've rather conveniently forgotten so much about extending the backoffice as I'm not a big fan of angular and this version is getting very long in the tooth now! Looking forward to doing all this the web components/plain JS way.
I've been using Paul Seals/Dave Westboroughs excellent demos for adding a CSHTML view to Block Lists instead of the angular method. It's working really well.
My manifest looks like this for my custom blocklist renderer.
But i'm getting an exception in the logs and backoffice wont load, I guess this may have something to do with the absolute URL instead of starting in ~/App_Plugins/*.
[12:04:25 ERR] An unhandled exception has occurred while executing the request.
Smidge.BundleNotFoundException: A bundle with the name:umbraco-backoffice-css could not be found.
if you can't do that, then the loader way is probibly the way you will have to go. but you don't need to do asset.load or anything, you could go vaniila js and document.CreateElement the link and then add it to the document head?
What the wrapper will give you the opportunity to add it when the user logs in - you could in theory - try to load it in a script without waiting for anything as long as you are not dependent on anything else? you could inject it into the head of the page.
I think Umbraco also has the LazyLoad library installed (it's what the assets service is using).
Thanks so much for the advice, I went ahead and added another file to the manifest and as you recommended kept it vanilla JS.
(function () {
loadFont = function () {
// create the <link> tag for the font
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'https://cloud.typography.com/fonts.css';
// reference the <head>, add the <link>
var head = document.getElementsByTagName('head')[0];
head.appendChild(link);
};
loadFont ();
})();
Worked a treat, I'm really enjoying working in Umbraco 10 and looking forward to getting a set of licences for uSync - which reminds me I really need to chase that up with legal and finance as I cannot remember where it was left :-)
Inject into the head of umbraco backoffice
Is there an easy way to inject a stylesheet link for a custom font into the head of the Umbraco backoffice?
So that I can render the font in my block list views?
Hi,
I you "only" want to inject a stylesheet into the backoffice, then you can do that by creating a package.manifest file in a folder inside
app_pluigns
folder (e.gapp_plugins/myfolder/package.manifest
)e.g
if you need to do something more complex, then you can inject things via angular, by having a run event (more advanced).
There is an example of how this is done in the BackOffice Themes Package this code uses a loader, to dynamically load css into the back office based on the user selected themes.
Hi Kevin
Thanks for the quick reply.
I've rather conveniently forgotten so much about extending the backoffice as I'm not a big fan of angular and this version is getting very long in the tooth now! Looking forward to doing all this the web components/plain JS way.
I've been using Paul Seals/Dave Westboroughs excellent demos for adding a CSHTML view to Block Lists instead of the angular method. It's working really well.
My manifest looks like this for my custom blocklist renderer.
But i'm getting an exception in the logs and backoffice wont load, I guess this may have something to do with the absolute URL instead of starting in ~/App_Plugins/*.
I need to have the line injected as
as @import won't work with this cloud provider.
Any ideas?
:( yeah i was about to suggest an import.
if you can't do that, then the loader way is probibly the way you will have to go. but you don't need to do asset.load or anything, you could go vaniila js and
document.CreateElement
the link and then add it to the document head?What the wrapper will give you the opportunity to add it when the user logs in - you could in theory - try to load it in a script without waiting for anything as long as you are not dependent on anything else? you could inject it into the head of the page.
I think Umbraco also has the LazyLoad library installed (it's what the assets service is using).
so maybe
LazyLoad('cssPathhere')
? will work?Hey Kevin
Thanks so much for the advice, I went ahead and added another file to the manifest and as you recommended kept it vanilla JS.
Worked a treat, I'm really enjoying working in Umbraco 10 and looking forward to getting a set of licences for uSync - which reminds me I really need to chase that up with legal and finance as I cannot remember where it was left :-)
is working on a reply...