Skip to content

Commit

Permalink
Merge pull request #49 from ngibbonssdl/hotfix/expandEmbeddedModels
Browse files Browse the repository at this point in the history
Fully expand entity models in RTF fields
  • Loading branch information
rwsigiles authored Sep 28, 2022
2 parents 68ddad4 + a251009 commit 0f9cfa3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Sdl.Web.Tridion.Templates.R2/Data/DataModelBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private object GetFieldValue(XmlElement xmlElement, int expandLinkDepth)
if (xmlElement.SelectSingleElement("xhtml:*") != null)
{
// XHTML field
return BuildRichTextModel(xmlElement);
return BuildRichTextModel(xmlElement, expandLinkDepth);
}

if (xmlElement.SelectSingleElement("*") != null)
Expand Down Expand Up @@ -292,7 +292,7 @@ private ViewModelData GetLinkFieldValue(IdentifiableObject linkedItem, int expan
return Pipeline.CreateKeywordModel(linkedKeyword, expandLinkDepth - 1);
}

protected RichTextData BuildRichTextModel(XmlElement xhtmlElement)
protected RichTextData BuildRichTextModel(XmlElement xhtmlElement, int expandLinkDepth = 0)
{
XmlDocument xmlDoc = xhtmlElement.OwnerDocument;
IList<EntityModelData> embeddedEntities = new List<EntityModelData>();
Expand All @@ -301,7 +301,7 @@ protected RichTextData BuildRichTextModel(XmlElement xhtmlElement)
Component linkedComponent = Pipeline.Session.GetObject(xlinkElement) as Component;
if (xlinkElement.LocalName == "img" || ShouldBeEmbedded(linkedComponent))
{
EntityModelData embeddedEntity = Pipeline.CreateEntityModel(linkedComponent, ct: null, expandLinkDepth: 0);
EntityModelData embeddedEntity = Pipeline.CreateEntityModel(linkedComponent, ct: null, expandLinkDepth: expandLinkDepth);

// Map each attribute to a metadata field

Expand Down

0 comments on commit 0f9cfa3

Please sign in to comment.