Skip to content

Commit

Permalink
Allows for entity models in RTF to be fully expanded - based upon the…
Browse files Browse the repository at this point in the history
… expandLinkDepth set in a template
  • Loading branch information
Neil Gibbons committed Sep 28, 2022
1 parent 68ddad4 commit a251009
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 a251009

Please sign in to comment.