Sitecore:在页面编辑器模式下检测用户

Wen*_*Hao 8 sitecore sitecore7 page-editor

我可以使用代码知道如何检测用户是否处于页面编辑器模式?这是因为,我有一个组件,当用户从页面编辑器浏览时,它将搜索master_index文件夹而不是web_index文件夹.

小智 27

请检查: if (Sitecore.Context.PageMode.IsPageEditorEditing)

也在使用Sitecore 6.6,它不依赖于Sitecore 7.

请查看Martina Welander撰写的这篇Sitecore 博客文章.

要检查是否正常页面使用: if (Sitecore.Context.PageMode.IsNormal)

要检查预览模式是否使用: if (Sitecore.Context.PageMode.IsPreview)

还有其他PageMode:

  • IsPageEditorClassic
  • IsPageEditorDesigning
  • IsPageEditorEditing
  • IsPageEditorNavigating

如果您很好奇,可以使用Reflector或dotPeek检查此类:Sitecore.Context.PageMode来自Sitecore.Kernel程序集.