Try our conversational search powered by Generative AI!

Highlight the current environment in CMS editor

Vote:
 

Hi,

In our team we have members who works in multiple environments simultaneously and I'm trying to minimize the risk of someone making a change in the wrong environment.
I'm mostly worrying about the production env so my idea is to change the editor background in production so it will be super clear when the member is currently editing in production.

What is the easiest way to achieve this goal?

I need at least two things:
1. A way to flag an environment as production.
2. A way to load and apply a style based on if the flag(1) is set on the CMS editor page.

The solution shouldn't be anything that needs to check the url during every request, we don't want extra overhead and web.config transforms won't do it either because release builds are used in other envs than prod.


Are there any other built-in features in EPiServer CMS that could help me solve the original issue in any other way?

#230440
Edited, Nov 05, 2020 10:36
Vote:
 

Few cents:

1) Even generic hosting runtime in .NET Core relies on some variables in configuration context (either coming from appSettings.json file, env variables, command line parameters, whichever source...). By default named ASPNETCORE_ENVIRONMENT.

2) If you want to follow similar approach - you can introduce new variable in web.config or any other config file you are using and override with proper value for proper environment (assuming that you might be using variable transformations not at build time, but at deploy time).

3) You can use client resourceregistration ferature in Episerver to accomplish this. Code sample:

[ClientResourceRegistrator]
public class EnvSpecificStyleInjection : IClientResourceRegistrator
{
    public void RegisterResources(IRequiredClientResourceList requiredResources)
    {
        // do the magic here
    }
}
#230546
Nov 08, 2020 19:00
Mikael Porttila - Nov 09, 2020 11:10
Hi, thank you for the reply, I looking into the IClientResourceRegistrator, as I understand this will register resources globally, is there a way here to register resources for the epi cmd editor pages only? Basically register a css-file for all pages under "episerver/cms/"?
Ha Bui - Mar 08, 2023 13:30
Hi, just want to extend good answer from Valdis: inside RegisterResources then you just check the context mode with IContextModeResolver then should be fine!
https://world.optimizely.com/csclasslibraries/cms/EPiServer.Web.IContextModeResolver?version=11
Hope that help!
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.