Differences between CmsHttpContext.Current.Mode and WebAuthorContext.Current.Mode


This week I received two questions on confusion caused by the fact that the difference between CmsHttpContext.Current.Mode and WebAuthorContext.Current.Mode was not clear.



CmsHttpContext.Current.Mode - Publishing Mode


This mode reflects the current Publishing Mode of MCMS. So this mode indicates if the API will currently see the published or the unpublished version of the posting and if it is possible to update placeholder content or posting properties. The publishing mode of the CmsHttpContext is defined through the NRMODE querystring parameter. The following Publishing Modes exist:



  • Published - API only has access to the published version of the posting
  • Unpublished - API will see the unpublished version of the posting
  • Update - API is able to update content in placeholders and will see the content of the unpublished version versions of the posting
  • Staging - Similar to Published mode but used by Site Stager. Here links to other postings are rendered differently

The only way to switch the CmsHttpContext to a different mode is a redirect with a different NRMODE querystring parameter. Postings and Channels hold a property to give you the URL to redirect to: e.g.: Posting.UrlModePublished, Posting.UrlModeUnpublished, Posting.UrlModeUpdate


An alternative to a redirect would be to use the CmsApplicationContext. Here the publishing mode can be defined during the authentication. Be aware of the following articles when using this context:


Unable to authenticate as current user in ASP.NET
Creating scalable applications using the CmsApplicationContext



WebAuthorContext.Current.Mode - Mode of the Webauthor Console


This mode reflects the current mode of the Webauthor Console and whether or not the placeholder controls are rendered in authoring mode or not. There is actually no relationship between WebauthorContext mode and the Publishing mode! E.g. while WebAuthorContext mode is in authoring mode the publishing mode is in Unpublished mode and not - as some were expecting - in Update mode! This context supports the following modes:



  • PresentationPublished - that' the mode you see when you are in "Live Site" view
  • PresentationUnpublished - that's the mode you see when you are  in "Edit Mode"
  • PresentationPreview - that's the mode you get when clicking on the "Preview" button while being in "Edit Mode"
  • AuthoringNew - that's the mode you get when you are editing a posting which has not yet been saved
  • AuthoringReedit - that's the mode you get when you are editing an existing posting.
  • AuthoringPreview - that's the mode you get when clicking the "Preview" button while being in "Authoring Mode".
  • TemplatePreview - that's the mode you get when clicking the "Preview" button of a template in the template gallery

As you can see "Edit Mode" is actually not really while you are editing the posting but while you see the unpublished version and see the modifying actions like "Edit", "Approve", "Delete", ...


Editing can only be done in "Authoring Mode" - that's when you see the placeholder controls being rendered in a way that the content can be changed and that the Console shows the "Save" links.


WebAuthorContext mode is defined through the WBCMODE querystring parameter.


The only way to switch the WebAuthorContext to a different mode is a redirect with a different WBCMODE querystring parameter. The WebAuthorContext provides you with methods to get the correct URLs:



  • GetUrlForMode - this will give you the URL to redirect to for a specific HierarchyItem in a specific WebAuthorContext mode. It requires the Posting or the channel to be displayed and the WebAuthorContext mode to be used.
  • GetAuthoringNewUrl - this will give you the URL to get to authoring mode for a new posting. It requires a template and channel object and an optional posting object if a new connected posting should be authored.


How is an item saved when the publishing mode is Unpublished while WebAuthorContext is in Authoring mode?


When clicking the save button a redirect is done with NRMODE=Update which causes the publishing mode to go into Update mode. After the save is finished a second redirect happens back to NRMODE=Unpublished. Btw: that's the reason for the double refresh when saving a posting.


 

Comments (0)

Skip to main content