beautypg.com

Including an image link for results, Xslt code for image links, Image meta tag – Google Search Appliance Creating the Search Experience User Manual

Page 124

background image

Google Search Appliance: Creating the Search Experience

Advanced Customization Topics

124

Including an Image Link for Results

Placing small images in the search results enhances the visual appeal of the results page. Because
experience has trained many users to click icons and pictures, it is helpful to make each image a link to
the search result, just as the result title is a link to the result. The “HTML Form Example Page” on
page 113
shows image links presented in the results pages.

XSLT Code for Image Links

The thumbnail-sized image links in the example pages are derived from a small block of XSLT code
added after the variable declarations in the “single result” section of example-frontend_stylesheet.en.xslt.
To find this block in the example stylesheet, search for the comment text “






The XSLT image block iterates through each MT (meta tag) element in the result set and tests for non-
empty values for the tag product-image. Then it includes the meta tag value inside a link to the results
URL as represented by the concatenated variables protocol and escaped_url.

It is important to locate this XSLT block after the variable declarations located at the beginning of the
“single result” XSLT block. Because the image block uses two of these variables, it will throw an error in
the XSLT stylesheet editor if it is located before the variable is declared.

Image Meta Tag

Each product description page in this example includes a meta tag named product-image containing
an absolute link to a thumbnail image. Because relative links do not work in the search results page, the
meta tag values must be absolute links. For example, on mywebserver the prince nymph example page
would include this meta tag:

The exact meta tag name is important, because it is required as a value for the search request
parameter getfields and also it is tested in a conditional clause in the XSLT code. All pages for which
you want to present a results image must include a meta tag like this one, with the name properly
referenced in the stylesheet and in getfields.

You must explicitly retrieve the meta tags you want from the result set in order for them to be
transformed by the XSLT code. You can do this by adding getfields="meta_tag_name" to your search
request, or use getfields="*" to retrieve all meta tags. See the Search Protocol Reference for more
information on adding query parameters to the search request.