Portal Engine
Version 3.x > Portal Engine > KB Article - Redirecting to default.aspx when another culture is clicked View modes: 
User avatar
Member
Member
Darren - 12/11/2008 6:31:29 AM
   
KB Article - Redirecting to default.aspx when another culture is clicked
This is great and something I want to do but I don't think it's working properly.

I've made the changes described but it just appends 'default.aspx' to the end of the current path. So in the root it works fine but if I'm in for instance /brochures/ then the URL path is /brochures/default.aspx which obviously doesn't exist. This of course gives me a 404 which is the problem I had before when switching cultures due to the sites not being mirror images of each other.

Any idea what I might be doing wrong?

User avatar
Kentico Support
Kentico Support
kentico_radekm - 12/15/2008 4:34:16 AM
   
RE:KB Article - Redirecting to default.aspx when another culture is clicked
Hello Darren.

We have updated this Knowledge base article, since previously it works for first level pages only.

To achieve requested functionality, please do following (in <project folder>/CMSWebParts/General/languageselectionwithflags.ascx.cs file):

Under “foreach (DataRow dr in ds.Tables[0].Rows)” in SetupControl() method please add:

/////////
string YourDomainName = "http://www.mydomain.com/"; //Please change to requested domain name. Must be ended by slash "/"!
string YourHomePageAspxFileName = "default.aspx"; // This is default value, please do not change
/////////

Then please change this piece of code:
if (this.ShowCultureNames)
{
// original code
}
else
{
// original code
}

Like:

if (this.ShowCultureNames)
{
ltlHyperlinks.Text += "<a href=\"" + YourDomainName + YourHomePageAspxFileName + "?lang=" + dr["CultureCode"].ToString() + "\">";
ltlHyperlinks.Text += dr["CultureShortName"].ToString();

// Set surrounding div css class
selectionClass = "languageSelectionWithCultures";
}
else
{
ltlHyperlinks.Text += "<a href=\"" + YourDomainName + YourHomePageAspxFileName + "?lang=" + dr["CultureCode"].ToString() + "\">";

// Set surrounding div css class
selectionClass = "languageSelection";
}

Now it works for all pages.

Best Regards,
Radek Macalik