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

Commit fdc4617

Browse files
Updated DetachedPublishedContent to inherit a number of base properties from the containing node. Should help to fix issue #24
1 parent 3dec042 commit fdc4617

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

Src/Our.Umbraco.DocTypeGridEditor/Helpers/DocTypeGridEditorHelper.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Umbraco.Core.Models.PublishedContent;
1212
using Umbraco.Core.PropertyEditors;
1313
using Umbraco.Core.Services;
14+
using Umbraco.Web;
1415

1516
namespace Our.Umbraco.DocTypeGridEditor.Helpers
1617
{
@@ -78,8 +79,14 @@ public static IPublishedContent ConvertValueToContent(string id, string docTypeA
7879
// Do nothing, we just want to parse out the name if we can
7980
}
8081

81-
return new DetachedPublishedContent(nameObj == null ? null : nameObj.ToString(), publishedContentType,
82-
properties.ToArray());
82+
// Get the current request node we are embedded in
83+
var pcr = UmbracoContext.Current.PublishedContentRequest;
84+
var containerNode = pcr != null && pcr.HasPublishedContent ? pcr.PublishedContent : null;
85+
86+
return new DetachedPublishedContent(nameObj == null ? null : nameObj.ToString(),
87+
publishedContentType,
88+
properties.ToArray(),
89+
containerNode);
8390
}
8491
});
8592
}

Src/Our.Umbraco.DocTypeGridEditor/Models/DetachedPublishedContent.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,18 @@ internal class DetachedPublishedContent : PublishedContentBase
1414
private readonly PublishedContentType _contentType;
1515
private readonly IEnumerable<IPublishedProperty> _properties;
1616
private readonly bool _isPreviewing;
17+
private readonly IPublishedContent _containerNode;
1718

1819
public DetachedPublishedContent(string name,
1920
PublishedContentType contentType,
2021
IEnumerable<IPublishedProperty> properties,
22+
IPublishedContent containerNode = null,
2123
bool isPreviewing = false)
2224
{
2325
_name = name;
2426
_contentType = contentType;
2527
_properties = properties;
28+
_containerNode = containerNode;
2629
_isPreviewing = isPreviewing;
2730
}
2831

@@ -106,22 +109,22 @@ public override string UrlName
106109

107110
public override string WriterName
108111
{
109-
get { return null; }
112+
get { return _containerNode != null ? _containerNode.WriterName : null; }
110113
}
111114

112115
public override string CreatorName
113116
{
114-
get { return null; }
117+
get { return _containerNode != null ? _containerNode.CreatorName : null; }
115118
}
116119

117120
public override int WriterId
118121
{
119-
get { return 0; }
122+
get { return _containerNode != null ? _containerNode.WriterId : 0; }
120123
}
121124

122125
public override int CreatorId
123126
{
124-
get { return 0; }
127+
get { return _containerNode != null ? _containerNode.CreatorId : 0; }
125128
}
126129

127130
public override string Path
@@ -131,17 +134,17 @@ public override string Path
131134

132135
public override DateTime CreateDate
133136
{
134-
get { return DateTime.MinValue; }
137+
get { return _containerNode != null ? _containerNode.CreateDate : DateTime.MinValue; }
135138
}
136139

137140
public override DateTime UpdateDate
138141
{
139-
get { return DateTime.MinValue; }
142+
get { return _containerNode != null ? _containerNode.UpdateDate : DateTime.MinValue; }
140143
}
141144

142145
public override Guid Version
143146
{
144-
get { return Guid.Empty; }
147+
get { return _containerNode != null ? _containerNode.Version : Guid.Empty; }
145148
}
146149

147150
public override int Level

0 commit comments

Comments
 (0)