Dynamic RTE stylesheet
# help-with-umbraco

Jamie T

02/07/2024, 3:22 PM
Hi all, we are creating a multi-tenant solution and having a play with the RTE styles, but ideally we would like different styles depending on the tenant you are editing content for. As you set the stylesheet file on the data type it's set for everyone. Any ideas how we can make this a little more dynamic ? Or any other ideas ?


02/08/2024, 9:11 AM
Maybe you can tap into or override these controllers: GetRulesByName is called when a RTE has a stylesheet attached, so maybe you can circumvent the default behavior when a specific file name is sent. GetConfiguration is called whenever af RTE is loaded in the backoffice. It doesn't contain stylesheet information but it does contain the configuration options in case you want to change those as well.


02/08/2024, 10:56 AM
You can create an RTE profile for each tenant and use that on your RTE field?
That's OOTB functionallity, or are you sharing the same document types across tenants?

Jamie T

02/11/2024, 1:32 PM
Yeah we share data types across tenants. The above is interesting, if only I could add a custom data attribute or an extra css selector into the RTE id be able to then use the Rte css to use that to override - but can’t see anything obvious without having to edit Umbraco code which we are trying to avoid especially as with the new back office we’d probably then have to revisit whatever we do here
Reconfiguration is useful if I could override this and know which node is requesting as Tinymce has the ability to set a ‘body_class’ in the config which if I could inject would solve the puzzle
In case anyone wants to do anything similar, this is what I got working. This essentially intercepts the response from
and appends the css file we want, it also adds a class to the body tag which will give selector styling options. I get the current node id from the url and pass this to an API call which goes off and finds the theme property.