With regards to publishing and rendering in TOM.NET, I know the following is true for the legacy publishing framework (pre Web 8):
Template Builder
PublicationTarget
is null
, RenderMode
is PreviewDynamic
CME Preview
PublicationTarget
ID is tcm:0-0-0
(or TcmUri.UriNull
), RenderMode
is PreviewDynamic
Session Preview
PublicationTarget
ID is the real Target ID, RenderMode
is PreviewDynamic
Publish
PublicationTarget
ID is the real one, RenderMode
is Publish
Then you can use the following example code to determine the current mode:
private CurrentMode GetCurrentMode()
{
RenderMode renderMode = _engine.RenderMode;
if (renderMode == RenderMode.Publish)
{
return CurrentMode.Publish;
}
if (renderMode == RenderMode.PreviewDynamic)
{
if (_engine.PublishingContext.PublicationTarget == null)
{
return CurrentMode.TemplateBuilder;
}
PublicationTarget target = _engine.PublishingContext.PublicationTarget;
if (target.Id.Equals(TcmUri.UriNull))
{
return CurrentMode.CmePreview;
}
return CurrentMode.SessionPreview;
}
return CurrentMode.Unknown;
}
private enum CurrentMode
{
TemplateBuilder,
CmePreview,
SessionPreview,
Publish,
Unknown
}
How does this change in the new publishing framework introduced in SDL Web 8?