Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes to use direct link to publish in case of linked component is … #55

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions Sdl.Web.Tridion.Templates.R2/Data/DataModelBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,24 @@ protected RichTextData BuildRichTextModel(XmlElement xhtmlElement, int expandLin
xlinkElement.RemoveXlinkAttributes();
continue;
}
// Default behaviour: Hyperlink to MM Component: add the Binary and set the URL as href
string binaryUrl = Pipeline.RenderedItem.AddBinary(linkedComponent).Url;

string binaryUrl;
// if binary is ECL item then use GetDirectLinkToPublished for binaryUrl
if (IsEclItem(linkedComponent))
{
//expandLinkDepth is 0, because we are only trying to fetch binary url
EntityModelData linkedEntity = Pipeline.CreateEntityModel(linkedComponent, ct: null, expandLinkDepth: 0);
if(linkedEntity == null || linkedEntity.BinaryContent == null)
{
throw new DxaException($"Unable to determine binary URL for ECL item: {linkedComponent.Id}");
}
binaryUrl = linkedEntity.BinaryContent.Url;
}
else
{
// Default behaviour: Hyperlink to MM Component: add the Binary and set the URL as href
binaryUrl = Pipeline.RenderedItem.AddBinary(linkedComponent).Url;
}
xlinkElement.SetAttribute("href", binaryUrl);
xlinkElement.RemoveXlinkAttributes();
}
Expand Down