Using localized strings in XSLT of Summary Link Webpart

Hello All,

Discussion Topic

In my project we have requirement like, we have to display a localized string in Summary Link webpart. String like “See all”, since we have multilingual site we will require localized version of this string. So we decided to get string “See all” string from the resource file in XSLT.

So here we are going to discuss how to get the value from resource files in Summary Link webpart XSLTs.

Description

SummaryLink webpart is derived from DataFormWebPart webpart as:

Microsoft.SharePoint.WebPartPages.DataFormWebPart

Microsoft.SharePoint.Publishing.WebControls.CmsDataFormWebPart

Microsoft.SharePoint.Publishing.WebControls.SummaryLinkWebPart

There is <ParameterBindings> property of DataFormWebPart webpart. This property makes the resource strings available in XSLTs.

Syntax for <ParameterBindings> property in SummaryLinkWebPart definition file is as:

  1. <property name="ParameterBindings" type="string" >  
  2.   
  3. <ParameterBinding Name="testparameter" Location="Resource(resourcefilename,resourcestringwhosevalueneedtomakeavailable)" />  
  4.   
  5. </property>  
In above syntax only we need to mention the <ParameterBindings> property in SummaryLinkWebPart definition file.

Now here,

  1. Location specifies the Resource function. SharePoint foundation uses Resource function to get the value of specified resource strings. You will get more details here.

  2. Name is used in XSLT as parameter.

Now once you specified, in XSLT you will get this value as a parameter. I.e. in SummaryLinkMain.xsl file you will get the value from resource file by define it as follows:

  1. <xsl:param name=" testparameter" />  
Here parameter name is same as specified in webpart definition file, i.e testparameter. Once I define this parameter in XSLT then I can use this value in XSLT as:
  1. <xsl:value-of select="$testparameter "/>  
Also we can pass this value in ItemStyle.xslt also by using <xsl:with-param> element as: 
  1. <xsl:apply-templates select="." mode="itemstyle">  
  2.        <xsl:with-param name="teste1234" select="$tes123t"></xsl:with-param>  
  3. </xsl:apply-templates>  
These XSLTs are always having fun to work Enjoy!