问题
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:
- How can I tell the difference between CMS Preview and DYnamic Preview in template code
- 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