Change result name in search appliance

For various reasons, I would really like to show the file name as a result in the Google Mini search results, and not by default. I can do this by replacing

<!-- *** Result Title (including PDF tag and hyperlink) *** -->
...
<span class="l">
    <xsl:choose>
      <xsl:when test="T">
        <xsl:call-template name="reformat_keyword">
          <xsl:with-param name="orig_string" select="T"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise><xsl:value-of select="$stripped_url"/></xsl:otherwise>
    </xsl:choose>
</span>

with

<span class="l">
    <xsl:value-of select="$stripped_url"/>
</span>

It remains to do the following:

  • Replace% 20 with spaces
  • Trim the url to leave only the final file name
  • Trim file extension from end

How can i do this?

+3
source share
2 answers

I get it. A lot of code and functions already existed, I just had to know what I was looking for and massage the results a bit.

Return the document file name:

<span class="l">
    <xsl:variable name="document_title">
        <xsl:call-template name="last_substring_after">
            <xsl:with-param name="string" select="substring-after(
                                                  $temp_url,
                                                  '/')"/>
            <xsl:with-param name="separator" select="'/'"/>
            <xsl:with-param name="fallback" select="'UNKNOWN'"/>
        </xsl:call-template>
    </xsl:variable>

Replace% 20 with spaces:

    <xsl:call-template name="replace_string">
        <xsl:with-param name="find" select="'%20'"/>
        <xsl:with-param name="replace" select="' '"/>
        <xsl:with-param name="string" select="$document_title"/>
    </xsl:call-template>
</span>
+2
source

In addition, the file extension can be removed using the additional variable find / replace.

<xsl:variable name="document_title_remove_extension">
    <xsl:call-template name="replace_string">
      <xsl:with-param name="find" select="'.pdf'"/>
      <xsl:with-param name="replace" select="''"/>
      <xsl:with-param name="string" select="$document_title"/>
    </xsl:call-template>
  </xsl:variable>
  <xsl:call-template name="replace_string">
      <xsl:with-param name="find" select="'%20'"/>
      <xsl:with-param name="replace" select="' '"/>
      <xsl:with-param name="string" select="$document_title_remove_extension"/> 
  </xsl:call-template>
</span>
0
source

All Articles