我是否可以使用代码了解如何检测用户是否处于页面编辑器模式? 这是因为,我有一个组件,当用户从页面编辑器浏览时,它将搜索master_index文件夹而不是web_index文件夹。
答案 0 :(得分:26)
请查看:if (Sitecore.Context.PageMode.IsPageEditorEditing)
也正在使用Sitecore 6.6,它不依赖于Sitecore 7。
请查看Martina Welander的此Sitecore blog post。
检查页面是否正常使用:if (Sitecore.Context.PageMode.IsNormal)
要检查预览模式是否使用:if (Sitecore.Context.PageMode.IsPreview)
也是其他PageMode:
如果您很好奇,可以使用Reflector或dotPeek查看此类: Sitecore.Context.PageMode 来自 Sitecore.Kernel 程序集。
答案 1 :(得分:2)
我认为你只想背驮于上下文数据库名称 -
,而不是检查页面模式var indexName = Sitecore.Context.Database.Name + "_index";
答案 2 :(得分:0)
我正在使用这种语法来为JS检测添加一个类,相同的代码可以用于位修改的后端检测:
<html class="@(Sitecore.Context.PageMode.IsPageEditor ? "inexpeditor" : "notexpeditor")">