Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

How to: Change the Icon for a Search Result

SharePoint 2007

To customize the icon that is used to represent a given type of search result, you must first understand how Enterprise Search in Microsoft Office SharePoint Server 2007 associates an icon image with a search result item. Then, you can decide which default behavior you need to modify based on the types of results you want to customize.

Enterprise Search in Microsoft Office SharePoint Server 2007 first determines whether a result item has an associated contentclass managed property. If the item does, Enterprise Search in Microsoft Office SharePoint Server 2007 check for an image in the path %Program Files%\Common Files\Microsoft Shared \Web Server Extensions\12\TEMPLATE\IMAGES that has a name that corresponds to the value of the contentclass property. The image file name replaces all colons (":") and pound symbols ("#") in the property value with dashes, and appends "16.gif." For example, the image file corresponding to a contentclass property value of "sample:contentproperty#value" would be "sample-contentproperty-value16.gif."

If the result item does not have a contentclass managed property, or if an image for that property value does not exist, Enterprise Search in Microsoft Office SharePoint Server 2007 checks whether an image is associated with the result item's file name extension. Icons for file types are specified in the docicon.xml file, which you can find in the path %Program Files%\Common Files\Microsoft Shared \Web Server Extensions\12\TEMPLATE\XML.

If neither method returns an icon for a result item, Enterprise Search in Microsoft Office SharePoint Server 2007 uses the default image (located in%Program Files%\Common Files\Microsoft Shared \Web Server Extensions\12\TEMPLATE\IMAGES\html16.gif).

You can change the image associated with a search result item in one of three ways, as follows:

  • Change or add an image for a contentclass managed property value.

  • Change or add an image for a file name extension.

  • Change the image for a set of results when that set is displayed by a Search Core Results Web Part.

To change or add an image for a contentclass managed property value

  1. Create an image file with a name that corresponds to the name of the contentclass managed property value you want. Replace all colons (":") and pound symbols ("#") in the property value with dashes, and then append "16.gif" to the image file name.

  2. Drop this image file in the path %Program Files%\Common Files\Microsoft Shared \Web Server Extensions\12\TEMPLATE\IMAGES. If a file already exists in that directory for this property value, replace it with your new file.

  3. Search for a term that will return items with the contentclass managed property value you want, and then verify that the new image appears for those items.

To change or add an image for a file name extension

  1. Drop the image file you want in the path %Program Files%\Common Files\Microsoft Shared \Web Server Extensions\12\TEMPLATE\IMAGES.

  2. Open the docicon.xml file located in the path %Program Files%\Common Files\Microsoft Shared \Web Server Extensions\12\TEMPLATE\XML.

  3. In the ByExtension node of the docicon.xml file, add or edit a mapping so that it uses the image file that you added in step 1 of this procedure. For example, a mapping for the file name extension .sample would look like the following.

    <Mapping Key="sample" Value="lotus16.gif"/>
    
  4. Restart Microsoft Internet Information Services (IIS) to flush the cache.

  5. Search for a term that will return items with the file name extension you want, and then verify that the new image appears for those items.

To change the image for a set of results in a Search Core Results Web Part

  1. Access the XSL property of the Search Core Results Web Part by following the instructions in How to: View and Edit the Search Results XSLT Transformation.

  2. Locate the following tag in the XSLT.

    <xsl:template match="Result">
    
  3. Edit the image source URL that appears inside that XSLT tag so that it uses the image you want.

    <a href="{$url}" id="{concat('CSR_IMG_',$id)}" title="{$url}"> <img align="absmiddle" src="{imageurl}" border="0" alt="{imageurl/@imageurldescription}" /> </a>
    

    The image URL that you use here will appear for every search result item in this Web Part.

  4. Search for any term that will return a result on the page that uses the Search Core Results Web Part that you have modified. Verify that the new image appears for all result items.

Community Additions

ADD
Show:
© 2015 Microsoft