Problems detecting when we are doing CMS Preview vs Dynamic Preview in 2012 UI/XM

跟風遠走 提交于 2019-12-10 17:19:42

问题


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.

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)

Looking at the possible values for RenderMode in the .NET API we have Publish, PreviewStatic, and PreviewDynamic.

So my questions are:

  1. How can I tell the difference between CMS Preview and DYnamic Preview in template code
  2. When (if at all) is the RenderMode PreviewStatic?

回答1:


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 Preview - RenderMode:DynamicPreview PublicationTarget:null
  • Dynamic Preview - RenderMode:DynamicPreview PublicationTarget:not null
  • Normal Publish - RenderMode:Publish PublicationTarget: not null

Stil not sure when PreviewStatic is used though...?



来源:https://stackoverflow.com/questions/12929190/problems-detecting-when-we-are-doing-cms-preview-vs-dynamic-preview-in-2012-ui-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!