Tag : experience-explorer

Checking for Experience Explorer Context in Sitecore 9

With the release of Sitecore 9, a underappreciated DLL was removed: Sitecore.ExperienceExplorer.Business.dll.

I’ve honestly never paid much attention to that DLL. The one thing I used it for, however, was determining if the current context was Experience Explorer. Synthesis made use of this:

public class SitecoreRenderingContext : IRenderingContext
    public bool IsExperienceExplorer => Sitecore.ExperienceExplorer.Business.Managers.ModuleManager.IsExpViewModeActive;

The new way of handling this is via the IsExplorerMode method in the ExplorerContext class. This isn’t a static method, however. In order to maintain the static context, the above line was changed to:

public bool IsExperienceExplorer => DependencyResolver.Current.GetService<IExplorerContext>().IsExplorerMode();

I’m typically not a the #1 fan of DependencyResolver, but I wanted to ensure backwards compatibility.

You’ll need to include the following DLLs:

  • Sitecore.ExperienceExplorer — this is for the ExplorerContext class
  • Sitecore.ExperienceExplorer.Core — this is for the IExplorerContext interface

The new version of Synthesis compiled against Sitecore 9 will be up on NuGet next week.