Skip to content
This repository was archived by the owner on Feb 10, 2024. It is now read-only.

Commit 83b3742

Browse files
committed
Removes dtgePreview from the RouteData values
This was a lazy design choice. Updated developer guide documentation to use `UmbracoContext.InPreviewMode` instead. Closes #123
1 parent 578c564 commit 83b3742

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

docs/developers-guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ Because we treat your data as a standard `IPublishedContent` entity, that means
139139

140140
#### Rendering Alternative Preview Content
141141

142-
If your front end view is rather complex, you may decide that you want to feed the back office preview an alternative, less complex view. To do this, within your Razor view/partial, check for a RouteData parameter `dtgePreview` being set to true to detect being in preview mode to provide an alternative view.
142+
If your front end view is rather complex, you may decide that you want to feed the back office preview an alternative, less complex view. To do this, within your Razor view/partial, check `UmbracoContext.InPreviewMode` is set to true to detect being in preview mode to provide an alternative view.
143143

144144
```
145145
@inherits Umbraco.Web.Mvc.UmbracoViewPage
146-
@if (ViewContext.RouteData.Values["dtgePreview"])
146+
@if (UmbracoContext.InPreviewMode)
147147
{
148148
// Render preview view
149149
}

src/Our.Umbraco.DocTypeGridEditor/Web/Controllers/DocTypeGridEditorSurfaceController.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
using System.Web.Mvc;
3-
using Our.Umbraco.DocTypeGridEditor.Extensions;
1+
using System.Web.Mvc;
42
using Our.Umbraco.DocTypeGridEditor.Web.Helpers;
53
using Umbraco.Core;
64
using Umbraco.Core.Models;
@@ -31,7 +29,7 @@ public string PreviewViewPath
3129

3230
public bool IsPreview
3331
{
34-
get { return ControllerContext.RouteData.Values.TryGetValue("dtgePreview", out object value) && Convert.ToBoolean(value); }
32+
get { return UmbracoContext.InPreviewMode; }
3533
}
3634

3735
protected PartialViewResult CurrentPartialView(object model = null)

src/Our.Umbraco.DocTypeGridEditor/Web/Extensions/HtmlHelperExtensions.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Web;
22
using System.Web.Mvc;
33
using System.Web.Mvc.Html;
4-
using Our.Umbraco.DocTypeGridEditor.Extensions;
54
using Our.Umbraco.DocTypeGridEditor.Web.Helpers;
65
using Our.Umbraco.DocTypeGridEditor.Web.Mvc;
76
using Umbraco.Core;
@@ -47,8 +46,7 @@ public static HtmlString RenderDocTypeGridEditorItem(
4746
{
4847
dtgeModel = content,
4948
dtgeViewPath = viewPath,
50-
dtgePreviewViewPath = previewViewPath,
51-
dtgePreview = isPreview
49+
dtgePreviewViewPath = previewViewPath
5250
};
5351

5452
// Try looking for surface controller with action named after the editor alias
@@ -86,8 +84,7 @@ public static HtmlString RenderDocTypeGridEditorItem(
8684
}
8785

8886
// Check for preview view
89-
if (string.IsNullOrWhiteSpace(previewViewPath) == false
90-
&& isPreview)
87+
if (string.IsNullOrWhiteSpace(previewViewPath) == false && isPreview)
9188
{
9289
var fullPreviewViewPath = $"{previewViewPath}{editorAlias}.cshtml";
9390
if (ViewHelper.ViewExists(helper.ViewContext, fullPreviewViewPath, true))

0 commit comments

Comments
 (0)