Will
Will

Reputation: 965

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

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?

Upvotes: 4

Views: 196

Answers (1)

Will
Will

Reputation: 965

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...?

Upvotes: 5

Related Questions