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

Commit a18179b

Browse files
committed
Changed the parameter name to "pageId"
This follows our approach in Stacked Content and gives the intent it for the Page, rather than a "node", (which becomes confusing in this modern NC/DTGE/StackedContent world) Added an additional check that the page ID is greater than 0. A newly created page has an ID of -1, which means that it isn't in the cache or database and would throw an exception.
1 parent 0867359 commit a18179b

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,23 @@ public object GetDataTypePreValues(string dtdId)
9494
}
9595

9696
[HttpPost]
97-
public HttpResponseMessage GetPreviewMarkup([FromBody] FormDataCollection item, [FromUri] int nodeId)
97+
public HttpResponseMessage GetPreviewMarkup([FromBody] FormDataCollection item, [FromUri] int pageId)
9898
{
99-
// Get page container node
100-
var page = UmbracoContext.ContentCache.GetById(nodeId);
101-
if (page == null)
99+
var page = default(IPublishedContent);
100+
101+
// If the page is new, then the ID will be zero
102+
if (pageId > 0)
102103
{
103-
// If unpublished, then fake PublishedContent (with IContent object)
104-
page = new UnpublishedContent(nodeId, Services);
104+
// Get page container node
105+
page = UmbracoContext.ContentCache.GetById(pageId);
106+
if (page == null)
107+
{
108+
// If unpublished, then fake PublishedContent (with IContent object)
109+
page = new UnpublishedContent(pageId, Services);
110+
}
105111
}
106112

107-
var culture = UmbracoContext.Application.Services.ContentService.GetById(nodeId).GetCulture();
113+
var culture = UmbracoContext.Application.Services.ContentService.GetById(pageId).GetCulture();
108114
System.Threading.Thread.CurrentThread.CurrentCulture = culture;
109115
System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
110116

src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.resources.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
'Failed to retrieve datatypes'
3535
);
3636
},
37-
getEditorMarkupForDocTypePartial: function (nodeId, id, editorAlias, contentTypeAlias, value, viewPath, previewViewPath) {
38-
var url = umbRequestHelper.convertVirtualToAbsolutePath("~/umbraco/backoffice/DocTypeGridEditorApi/DocTypeGridEditorApi/GetPreviewMarkup?dtgePreview=1&nodeId=" + nodeId);
37+
getEditorMarkupForDocTypePartial: function (pageId, id, editorAlias, contentTypeAlias, value, viewPath, previewViewPath) {
38+
var url = umbRequestHelper.convertVirtualToAbsolutePath("~/umbraco/backoffice/DocTypeGridEditorApi/DocTypeGridEditorApi/GetPreviewMarkup?dtgePreview=1&pageId=" + pageId);
3939
return $http({
4040
method: 'POST',
4141
url: url,

0 commit comments

Comments
 (0)