Saturday, January 8, 2011

How to enable VariationLabelMenu control in SharePoint 2010?

How to enable VariationLabelMenu control in SharePoint 2010?

SharePoint 2010 (and MOSS 2007) ships with a control called VariationLabelMenu that can be used on sites with site variations enabled. This control enables users to navigate to the related/equivalent pages in other language sites (for which the language packs are installed)

Even though this control is provided OOB in SharePoint 2010, few steps need to be followed to get it to work.

After everything has been configured correctly, you will see a nice little menu that looks like in the below picture. You can place it in the master page or page layout according to your needs.

In my case, I have german language pack installed and therefore the VariationLabelMenu control displays "Deutsch" in the dropdown options.


Go to the location Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES, find the file "VariationsLabelMenu.ascx" and edit it.
Add the below line to the contents of the file.

<cms:VariationsLabelEcbMenu id ="varlabelmenu1" DataSourceID="LabelMenuDataSource" DisplayText="Links" IsCallbackMode="true" runat="server" />

After this change, the VariationLabelMenu shows up in the ribbon but it messes up with the existing controls in the ribbon which is not very pleasant.

There are some side effects due to the above change. The page editing options in the ribbon menu gets shrunk as the ribbon needs to accommodate the "VariationLabelMenu" control.

As you can notice in the above picture, the page editing options have been messed up.
Ideally it should look like below:

Also the welcome control that displays the Personal Actions Menu (Welcome Menu) will be replaced with the VariationLabelMenu control as shown below:

From what I have noticed, the reason for the disappearance of the welcome menu and the improper displayof the page editing options in the ribbon are because of the VariationLabelMenu. So if we hide it in the ribbon and show it somewhere else on the page, things will look normal again.

I have searched for the VariationLabelMenu control's markup in the HTML generated by SharePoint. In my case, it is ctl00_ctl34_varlabelmenu1. The control ID may change depending on your master page settings.

<style type="text/css">
    #ctl00_ctl34_varlabelmenu1 {display:none;}

Include the above code any where in the master page / page layout and it will hide the VariationLabelMenu control in the ribbon.

Now it's time to add the VariationLabelMenu control somewhere else on the page.
Add the below line of code at the top of the master page.

<%@ Register TagPrefix="PublishingVariations" TagName="VariationsLabelMenu" src="~/_controltemplates/VariationsLabelMenu.ascx" %>

Find an appropriate location in the master page / page layout and add the below line of code which renders the VariationLabelMenu on the page.

<PublishingVariations:VariationsLabelMenu id="labelmenu1" runat="server"/>

No comments:

Post a Comment