SharePoint:替换搜索结果连接URL 金大昊(jindahao)

需求:

对搜索结果(只是针对BCS数据)的URL连接地址替换为需要的url地址。

解决办法:

 1.编辑“搜索核心结果webpart”。

 2.编辑xsl文件 

  。。。。
  <!--jindahao add replace funcation -->
    <xsl:template name="string-replace-all">
      <xsl:param name="text" />
      <xsl:param name="replace" />
      <xsl:param name="by" />
      <xsl:choose>
        <xsl:when test="contains($text, $replace)">
          <xsl:value-of select="substring-before($text,$replace)" />
          <xsl:value-of select="$by" />
          <xsl:call-template name="string-replace-all">
            <xsl:with-param name="text"
            select="substring-after($text,$replace)" />
            <xsl:with-param name="replace" select="$replace" />
            <xsl:with-param name="by" select="$by" />
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$text" />
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>
<xsl:template match="Result">
        <xsl:variable name="id" select="id"/>
        <xsl:variable name="currentId" select="concat($IdPrefix,$id)"/>
        <xsl:variable name="url" select="url"/>
        <!--jindahao add myUrl -->
        <xsl:variable name="myUrl">
          <xsl:call-template name="string-replace-all">
            <xsl:with-param name="text" select="url" />
            <xsl:with-param name="replace" select="'http://10.246.5.201:80/ProfilePages/_bdc/http___2k8-r2x64en/riskcontrol1_1.aspx'" />
            <xsl:with-param name="by" select="'http://www.baidu.com'" />
          </xsl:call-template>
        </xsl:variable>

 3.保存webpart 

努力后就不会后悔

原文地址:https://www.cnblogs.com/jindahao/p/2438897.html