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

Provide Localization parameter to ResolveLink when available #11

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions Sdl.Web.Mvc/Controllers/PageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ public virtual ActionResult Page(string pageUrl)
/// <returns>null - response is redirected if the URL can be resolved</returns>
public virtual ActionResult Resolve(string itemId, int localizationId, string defaultItemId = null, string defaultPath = null)
{
string url = SiteConfiguration.LinkResolver.ResolveLink(string.Format("tcm:{0}-{1}-64", localizationId, itemId));
var localization = SiteConfiguration.LocalizationResolver.GetLocalization(localizationId.ToString());

string url = SiteConfiguration.LinkResolver.ResolveLink(string.Format("tcm:{0}-{1}-64", localizationId, itemId), localization: localization);
if (url == null && defaultItemId != null)
{
url = SiteConfiguration.LinkResolver.ResolveLink(string.Format("tcm:{0}-{1}", localizationId, defaultItemId));
url = SiteConfiguration.LinkResolver.ResolveLink(string.Format("tcm:{0}-{1}", localizationId, defaultItemId), localization: localization);
}
if (url == null)
{
Expand Down
5 changes: 3 additions & 2 deletions Sdl.Web.Tridion/Mapping/DefaultModelBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public virtual void BuildEntityModel(ref EntityModel entityModel, IComponent com
Link link = (Link)entityModel;
if (String.IsNullOrEmpty(link.Url))
{
link.Url = SiteConfiguration.LinkResolver.ResolveLink(component.Id);
link.Url = SiteConfiguration.LinkResolver.ResolveLink(component.Id, localization: localization);
}
}

Expand Down Expand Up @@ -726,7 +726,7 @@ protected virtual object MapComponent(IComponent component, Type modelType, Loca
{
if (modelType == typeof(string))
{
return SiteConfiguration.LinkResolver.ResolveLink(component.Id);
return SiteConfiguration.LinkResolver.ResolveLink(component.Id, localization: localization);
}

if (!modelType.IsSubclassOf(typeof(EntityModel)))
Expand Down Expand Up @@ -909,6 +909,7 @@ protected virtual string ProcessPageMetadata(IPage page, IDictionary<string, str

protected virtual void ProcessMetadataField(IField field, IDictionary<string, string> meta)
{

if (field.FieldType==FieldType.Embedded)
{
if (field.EmbeddedValues!=null && field.EmbeddedValues.Count>0)
Expand Down
2 changes: 1 addition & 1 deletion Sdl.Web.Tridion/Mapping/DefaultProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public virtual void PopulateDynamicList<T>(ContentList<T> contentList, Localizat
ILinkResolver linkResolver = SiteConfiguration.LinkResolver;
foreach (Teaser item in queryResults)
{
item.Link.Url = linkResolver.ResolveLink(item.Link.Url);
item.Link.Url = linkResolver.ResolveLink(item.Link.Url, localization: localization);
}

contentList.ItemListElements = queryResults.Cast<T>().ToList();
Expand Down
2 changes: 1 addition & 1 deletion Sdl.Web.Tridion/Mapping/DefaultRichTextProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private RichText ResolveRichText(XmlDocument doc, Localization localization)
if (!string.IsNullOrEmpty(tcmUri))
{
// Try to resolve directly to Binary content of MM Component.
linkUrl = linkResolver.ResolveLink(tcmUri, resolveToBinary: true);
linkUrl = linkResolver.ResolveLink(tcmUri, true, localization);
}
}
if (!string.IsNullOrEmpty(linkUrl))
Expand Down