Sitecore: User Discovery in Page Editor Mode

Can I find out how to detect a user in page editor mode using code? This is due to the fact that I have a component, when the user views the page editor, he will search in the master_index folder instead of the web_index folder.

+8
sitecore sitecore7 page-editor
source share
3 answers

Please check: if (Sitecore.Context.PageMode.IsPageEditorEditing)

also working on Sitecore 6.6, it does not depend on Sitecore 7.

Please also mark this entry on Sitecore on the blog by Martina Velander.

To check if the normal use of the page is: if (Sitecore.Context.PageMode.IsNormal)

To check if the preview mode is used: if (Sitecore.Context.PageMode.IsPreview)

There are also other PageMode:

  • IsPageEditorClassic
  • IsPageEditorDesigning
  • IsPageEditorEditing
  • IsPageEditorNavigating etc.

If you're interested, you can check this class with the Reflector or dotPeek: Sitecore.Context.PageMode from the Sitecore.Kernel assembly.

+25
source share

Instead of checking the page mode, I think you just want to link the contents of the context database -

 var indexName = Sitecore.Context.Database.Name + "_index"; 
+2
source share

I use this syntax to add a class to detect JS, the same code can be used to detect on the side with a bit modification:

 <html class="@(Sitecore.Context.PageMode.IsPageEditor ? "inexpeditor" : "notexpeditor")"> 
0
source share

All Articles