问题描述
我可以知道如何使用代码在页面编辑器模式下检测用户吗?这是因为,我有一个组件,当用户从页面编辑器浏览时,它将在master_index文件夹而不是web_index文件夹中搜索.
Can I know how to detect user is in page editor mode using code?This is because, I have a component, when user browses from page editor, it will search in master_index folder instead of web_index folder.
推荐答案
请检查:if (Sitecore.Context.PageMode.IsPageEditorEditing)
还在Sitecore 6.6上运行,它不依赖于Sitecore 7.
also is working on Sitecore 6.6, it not depends on Sitecore 7.
请同时检查此Sitecore .
Please check also this Sitecore blog post by Martina Welander.
要检查页面是否正常,请使用:if (Sitecore.Context.PageMode.IsNormal)
To check if is normal page use: if (Sitecore.Context.PageMode.IsNormal)
要检查是否为预览模式,请使用:if (Sitecore.Context.PageMode.IsPreview)
To check if is preview mode use: if (Sitecore.Context.PageMode.IsPreview)
其他PageMode:
Also are others PageMode:
- IsPageEditorClassic
- IsPageEditorDesigning
- IsPageEditorEditing
- IsPageEditorNavigating 等
- IsPageEditorClassic
- IsPageEditorDesigning
- IsPageEditorEditing
- IsPageEditorNavigating, etc
如果您好奇,可以使用Reflector或dotPeek进行此类检查: Sitecore.Kernel 程序集中的 Sitecore.Context.PageMode .
If you are curious you can check with Reflector or dotPeek this class: Sitecore.Context.PageMode from Sitecore.Kernel assembly.
这篇关于Sitecore:在页面编辑器模式下检测用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!