@@ -99,6 +99,10 @@ public object GetDataTypePreValues(string dtdId)
99
99
[ HttpPost ]
100
100
public HttpResponseMessage GetPreviewMarkup ( [ FromBody ] PreviewData data , [ FromUri ] int pageId )
101
101
{
102
+ // Set DTGE's preview to be in "preview mode", (storing the original value in a temp variable for resetting it later).
103
+ var inPreviewMode = UmbracoContext . InPreviewMode ;
104
+ UmbracoContext . InPreviewMode = true ;
105
+
102
106
var page = default ( IPublishedContent ) ;
103
107
104
108
// If the page is new, then the ID will be zero
@@ -108,7 +112,7 @@ public HttpResponseMessage GetPreviewMarkup([FromBody] PreviewData data, [FromUr
108
112
page = UmbracoContext . ContentCache . GetById ( pageId ) ;
109
113
if ( page == null )
110
114
{
111
- // If unpublished, then fake PublishedContent (with IContent object)
115
+ // If unpublished, then fake PublishedContent
112
116
page = new UnpublishedContent ( pageId , Services ) ;
113
117
}
114
118
}
@@ -153,6 +157,9 @@ public HttpResponseMessage GetPreviewMarkup([FromBody] PreviewData data, [FromUr
153
157
var partialName = "~/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditorPreviewer.cshtml" ;
154
158
var markup = Helpers . ViewHelper . RenderPartial ( partialName , model , UmbracoContext . HttpContext ) ;
155
159
160
+ // Restore the "preview mode" to its original value
161
+ UmbracoContext . InPreviewMode = inPreviewMode ;
162
+
156
163
// Return response
157
164
var response = new HttpResponseMessage
158
165
{
0 commit comments