问题描述
我有模板代码 (2011 SP1),它通过检查 engine.RenderMode
(将是 PreviewDynamic
)来检测是否正在使用 CMS 预览.然后,这将确保应用服务器通常为发布的页面添加的内容(如 CSS、JS、导航元素等)被注入到呈现的输出中,从而使 CMS 中的预览看起来不错.
I have template code (2011 SP1) which detects if a CMS Preview was being used by checking engine.RenderMode
(which would be PreviewDynamic
). This would then ensure that stuff that would usually be added by the app server for the published pages (like CSS, JS, navigation elements etc.) is injected to the rendered output so the preview looks nice in the CMS.
Tridion 2012 UI/XM 为动态预览创建临时文件,结果发现在发布这些文件时,渲染模式也是 PreviewDynamic
,这给了我一个问题该页面实际上已发布,我不想注入内容(在这种情况下,应用服务器使用 .NET 母版页处理此问题)
The Tridion 2012 UI/XM creates temporary files for dynamic preview, and it turns out that in Publishing these files, the render mode is also PreviewDynamic
, which gives me a problem as in the situation when the page is actually published, I don't want to inject stuff (the app server takes care of this with a .NET master page in this case)
查看 .NET API 中 RenderMode
的可能值,我们有 Publish
、PreviewStatic
和 PreviewDynamic
.
Looking at the possible values for RenderMode
in the .NET API we have Publish
, PreviewStatic
, and PreviewDynamic
.
所以我的问题是:
- 如何在模板代码中区分 CMS 预览和动态预览之间的区别
- 什么时候(如果有的话)RenderMode
PreviewStatic
?
推荐答案
我有一个部分解决方案(第一个问题).如果您结合使用 RenderMode
和 engine.PublishingContext.PublicationTarget
,您可以检测 CMS 预览、动态预览与普通发布:
I have a partial solution (for first question). If you use a combination of RenderMode
and the engine.PublishingContext.PublicationTarget
you can detect CMS Preview vs Dynamic Preview vs Normal Publish:
- CMS 预览 - RenderMode:
DynamicPreview
PublicationTarget:null - 动态预览 - RenderMode:
DynamicPreview
PublicationTarget:not null - 普通发布 - RenderMode:
Publish
PublicationTarget:不为空
- CMS Preview - RenderMode:
DynamicPreview
PublicationTarget:null - Dynamic Preview - RenderMode:
DynamicPreview
PublicationTarget:not null - Normal Publish - RenderMode:
Publish
PublicationTarget: not null
仍然不确定何时使用 PreviewStatic...?
Stil not sure when PreviewStatic is used though...?
这篇关于检测我们在 2012 UI/XM 中进行 CMS 预览与动态预览时的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!