Technical support This forum is closed.
Version 1.x > Technical support > BUG: SearchResultRedirect.aspx.cs + Workaround View modes: 
User avatar
Member
Member
wahid - 5/19/2005 10:45:54 AM
   
BUG: SearchResultRedirect.aspx.cs + Workaround
Hi,
After a search result click using CMSSearchResults, SearchResultRedirect and idpath...
1. Page_Load of SearchResultRedirect starts by calling tree.SelectSingleNode with the idpath provided by the QueryString:
node = tree.SelectSingleNode(idpath, TreePathTypeEnum.IDPath);
If you call node.GetValue("AliasPath), the AliasPath returned will already contain the culture info.
2. Page_Load calls Functions.GetPageInfoDR with node:
Functions.GetPageInfoDR((string) node.GetValue("AliasPath"));
If multilingual support is used, GetPageInfoDR adds the culture to the AliasPath once more resulting in an aliasPath containing twice the culture info (/en-us/en-us/Home/...).

To workaround this, I removed the culture info from the aliasPath before calling GetPageInfoDR:
pageDR = Functions.GetPageInfoDR(Functions.RemoveCultureFromPath((string) node.GetValue("AliasPath")));
I prefered not to change Functions.cs.

The problem is that the part that sets the culture in SearchResultRedirect won't do it right if the Culture Info changes. What I did is put the new Culture Info in a variable newCultureInfo which I use to change the session and the cookie variables.

Here are the few lines of code I added or changed:
string newCultureInfo;
string nodeAliasPath;
.....
//changed: pageDR = Functions.GetPageInfoDR((string) node.GetValue("AliasPath"));
nodeAliasPath = (string) node.GetValue("AliasPath");
newCultureInfo = nodeAliasPath.Split('/')[1];
pageDR = Functions.GetPageInfoDR(Functions.RemoveCultureFromPath((string)node.GetValue("AliasPath")));
.....
//set the culture info
//HttpContext.Current.Session["CMSPreferredCulture"] = newAliasPath.Split('/')[1];
Functions.SetCurrentCulture(newCultureInfo);

Here is the SetCurrentCulture function I wrote and put in Functions.cs:
public static void SetCurrentCulture(string strCulture) {
//Sets the Cookie
if (HttpContext.Current.Request.Cookies["CMSPreferredCulture"] != null) {
HttpContext.Current.Response.Cookies["CMSPreferredCulture"].Value = strCulture;
}
else
HttpContext.Current.Response.Cookies.Add(new HttpCookie("CMSPreferredCulture", strCulture));
HttpContext.Current.Session["CMSPreferredCulture"] = strCulture;
}

User avatar
Guest
admin - 5/19/2005 2:37:09 PM
   
Re: BUG: SearchResultRedirect.aspx.cs + Workaround
Hi Wahid,

Thank you for posting this solution. We will look into this issue and will fix it in the nearest release.

Best Regards,