From a25100908d6811f36961be2b0c708f1d28241b2b Mon Sep 17 00:00:00 2001 From: Neil Gibbons Date: Wed, 28 Sep 2022 11:56:39 +0100 Subject: [PATCH] Allows for entity models in RTF to be fully expanded - based upon the expandLinkDepth set in a template --- Sdl.Web.Tridion.Templates.R2/Data/DataModelBuilder.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sdl.Web.Tridion.Templates.R2/Data/DataModelBuilder.cs b/Sdl.Web.Tridion.Templates.R2/Data/DataModelBuilder.cs index 93de7da..17e93ab 100644 --- a/Sdl.Web.Tridion.Templates.R2/Data/DataModelBuilder.cs +++ b/Sdl.Web.Tridion.Templates.R2/Data/DataModelBuilder.cs @@ -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) @@ -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 embeddedEntities = new List(); @@ -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