MUI Refinement panel

First of all in this blog post I am going to explain how I resolved this little issue, but if this is the best solution I don’t know feel free to comment and share your idea’s with me.

OOB SharePoint 2010 offers a refinement panel that works great with the if you don’t use multiple languages. Unfortunately the project where I’m currently working on is a SharePoint environment with multiple languages. After some testing with search and the refinement panel I noticed that the Managed Metadata wasn’t changing when I was switching languages. This also was confirmed at the BIWUG 30/11 by Joris Poelmans.

After some thinking and testing I came to the conclusion that if I can edit the xml that most of my issues would be solved.

Here is a piece of the XML file. For getting the right term we can get the Id from the Url property.

First thing we need to do is get the url and unescape it so it is readable.

var url = Uri.UnescapeDataString(cnode.Element("Url").Value);

We will convert /Search/Pages/XMLResults.aspx?k=ui&amp;r=%22owstaxIdGroentenx0020%2Dx0020Lx%22%3D%23560159a2%2D4d98%2D4722%2Da0b1%2D1b06893769e6%3A%22Ui%22 to /Search/Pages/XMLResults.aspx?k=ui&amp;r="owstaxIdGroentenx0020-x0020Lx"=#560159a2-4d98-4722-a0b1-1b06893769e6:"Ui"

Then we check if the url we got contains an Guid. If we look at the url we see owstaxIdGroentenx0020-x0020Lx"=#560159a2-4d98-4722-a0b1-1b06893769e6:"Ui". owstaxIdGroentenx0020-x0020Lx is the metadata property that is used to filter that certain field. #560159a2-4d98-4722-a0b1-1b06893769e6:"Ui" is the termguid with the term label(the label depends on how it is saved more about that in my previous post ).

Thus if the url contains “#” the url contains a termguid.

if (url.Contains("#"))

To get the id we have to know that the last id we find is the id we are going to filter.

var id = url.Substring(url.LastIndexOf("#") + 1).Split(':')[0];

if (id.Length == 37)

{

id = id.Substring(1);

}

We have to check the length of the id. sometimes the XML return the property Metadata_Tags. In the Metadata_Tags there will be an extra 0 in the id. e.g. “0560159a2-4d98-4722-a0b1-1b06893769e6”

When we have the id, we can get the term label in the current language.

Term term = sess.GetTerm(new Guid(id));

string result = string.Empty;

result = term.GetDefaultLabel(CultureInfo.CurrentUICulture.LCID);

For branding reasons if have chosen to limit the length of the of the term to display. After we get the result we can now change the value of the Value property with the term label.