Feedback
 
Did this article resolve your question/issue?

   

Your feedback is appreciated.

Please tell us how we can make this article more useful. Please provide us a way to contact you, should we need clarification on the feedback provided or if you need further assistance.

Characters Remaining: 1025

 


Article

Image as link creates incorrect link in second language

« Go Back

Information

 
Article Number000108818
EnvironmentProduct: Sitefinity
Version: 9.x, 10.x, 11.x, 12.x
OS: All supported OS versions
Database: All supported Microsoft SQL Server versions
Question/Problem Description

In every culture, the image link is pointing to the default culture.
An image widget is pointing to a page in another culture. When clicking on it the culture is stripped and a 404 page opens. 
The image link of the Image widget, when accessed from a non-default culture is pointing to the default culture.

Steps to Reproduce1. Create a page in two languages (e.g. English and Spanish)
2. On a different page drop the image widget - translate this page too
3. Open the widget's designer and select "This image is a link..." > "To selected page"
4. Point to the page created in step 1 for each language
5. Open the page on the frontend and click on the link

Expected: To open each link in the respective culture - e.g. http://localhost:7230/es/link
Actual: The culture parameter is stripped - e.g. http://localhost:7230/link, and the page doesn't open
Clarifying Information
Error Message
Defect/Enhancement NumberBug 264361
Cause
For more information about Bug 264361, see https://feedback.progress.com/Project/153/feedback/Details/264361
 
Resolution
Fixed in:
Sitefinity Patch 13.0.7300.0

Refer to Knowledge Base Article 000076924, How to update Sitefinity to hotfix, internal build or a patch for instructions on how to download and install the fix.
 
Workaround
1. Create a class ImageModelCustom which inherits from ImageModel
2. Override the GetViewModel and change the GetLinkedUrl method
3. In the GetLinkedUrl add the following:
private string GetLinkedUrl(SfImage image)
{
	string linkedUrl = null;

	if (this.UseAsLink && this.LinkedPageId != Guid.Empty)
	{
		var pageManager = PageManager.GetManager();
		var node = pageManager.GetPageNode(this.LinkedPageId);
		if (node != null)
		{
			var relativeUrl = node.GetFullUrl(CultureInfo.CurrentUICulture, false); // This line is different in the previous versions
			linkedUrl = UrlPath.ResolveUrl(relativeUrl, false);
		}
	}
	else if (this.UseAsLink && this.LinkedPageId == Guid.Empty)
	{
		linkedUrl = image.ResolveMediaUrl(false);
	}
	return linkedUrl;
}


4. Register the new model in the Global.asax:
protected void Application_Start(object sender, EventArgs e)
{
	Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(this.Bootstrapper_Initialized);
}

private void Bootstrapper_Initialized(object sender, ExecutedEventArgs e)
{
	if (e.CommandName == "Bootstrapped")
	{
		FrontendModule.Current.DependencyResolver.Rebind<IImageModel>().To<ImageModelCustom>();
	}
}

Check attached the complete ImageModelCustom.
Notes
The amount of votes an item in the feedback portal has is taken into consideration when determining its priority. Vote for the item using the Like and Dislike buttons in the right-hand side menu to affect the priority it has. By casting a vote the voter will also be subscribed to a mailing list to receive notifications about changes of the item such as when it is fixed or implemented.
 
Last Modified Date5/21/2020 7:06 AM