Google Search Appliance Creating the Search Experience Bedienungsanleitung Seite 126

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 141
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 125
Google Search Appliance: Creating the Search Experience Advanced Customization Topics 126
XSLT Code for Custom Text
The product descriptions in the results for the example are derived from a small block of XSLT code
added to the “Snippet Box” section of the stylesheet. This custom block includes and augments the
default code for displaying the snippet. Note the differences and similarities in the default snippet box
and the customized version in these two examples:
Default Snippet Box
<!-- *** Snippet Box *** -->
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="s">
<xsl:if test="$show_res_snippet != '0'">
<xsl:call-template name="reformat_keyword">
<xsl:with-param name="orig_string" select="S"/>
</xsl:call-template>
</xsl:if>
Custom Description Snippet Box
<!-- *** Snippet Box *** -->
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="s">
<!--Use description meta tag, if non-empty, in place of snippet-->
<xsl:choose>
<xsl:when test="MT/@N='description' and MT/@V!=''">
<xsl:value-of select="MT[@N = 'description']/@V"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="reformat_keyword">
<xsl:with-param name="orig_string" select="S"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
The custom description snippet block displays the description for each result that has a description
meta tag, or
MT
. If the XSLT engine does not find a valid description tag, it calls the standard template
rules to display the auto-generated snippet element
S
.
The custom version includes the rule to display a standard snippet, but applies that template only if
there is no valid description tag in the result. If you use this approach, make sure you have only one
instance of the
reformat_keyword
template that selects the snippet element.
Description Meta Tag
Most of the product pages in this example includes a meta tag named
description
that contains a
brief description of the product. For example, the copper john nymph page includes this meta tag:
<meta name="description" content="An excellent nymph for pocket water or tight-
line nymphing. The high proportion of wire tied into the body makes the copper
john sink quickly to depth." />
All pages for which you want to present custom text must include a meta tag like the above example,
with the name properly referenced in the stylesheet and retrieved in the search request using the query
parameter
getfields
. For pages that do not contain valid description tags, the stylesheet uses the
automated snippet derived from page text.
Seitenansicht 125
1 2 ... 121 122 123 124 125 126 127 128 129 130 131 ... 140 141

Kommentare zu diesen Handbüchern

Keine Kommentare