Home

Tuesday, December 02, 2008

SharePoint 3.0: Search Results: How to Add a Document Properties Hyperlink

Introduction

As for a document appearing in SharePoint 3.0 search results; the standard formatting includes a hyperlink to open the document. However, you may want your search results to also include a link to open the display form or edit form of the document's associated list item. This way users have the options of opening a document as well as viewing and editing document properties all from the search results page.


Step 1. Crawl the Item ID Crawled Property

* SharePoint Shared Services Administration > Search Settings > Metadata Property Mappings > Crawled Properties
* Search for ows_ID(Integer)
* Edit/Map Property: ows_ID
* Mappings to managed properties: Check to "Include values for this property in the search index"
* Click OK



Step 2. Create a Managed Property for the Document's List Item ID

* SharePoint Shared Services Administration > Search Settings > Metadata Property Mappings > Managed Properties
* New Managed Property
Name and type
Property
Name: OWSIDInteger
Description:
The type of information in this property: Integer
Mappings to crawled properties: Select - Include values from a single crawled property based on the order specified
Crawled properties mapped to this managed property: OWS_ID(Integer)
Use in scopes: No - Do not allow this property to be used in scopes



Step 3. Run a Full Crawl

* SharePoint Shared Services Administration > Search Settings > Content sources and crawl schedules > For each applicable content source, invoke the context menu and Start Full Crawl


Step 4. Make the New Managed Property Part of the Search Query

* Search Center site collection > search results page > search results web part > edit web part > Modify Shared Web Part
* Web part tool pane > Results Query Options > Selected Columns:
Modify the XML of Selected Columns to include the new managed property, OWSIDInteger

Reference:
How to: Change the Properties Returned in the Core Search Results
http://msdn2.microsoft.com/en-us/library/ms560074.aspx

Step 6. Test the Search Query to Ensure the New Managed Property is Returning Values

* Search Center site collection > search results page > search results web part > edit web part > Modify Shared Web Part
* Web part tool pane >Miscellaneous > XSL Editor:
Modify the XML so it returns raw XML results


Reference:
How to: View Search Results XML Data
http://msdn2.microsoft.com/en-us/library/ms546985.aspx


Step 5. Make the Managed Property Display in the Search Results

5A. Create an XML File Containing the Raw XML Representation of the Search Results
* Open an XML editor such as Visual Studio
* File > New > File > XML File
* Search Center > Perform a search (the results should still be coming back as raw XML)
* Copy the search results into the XML file
* Save the XML file to be used in Step 5B


5B. Create a new XSL Stylesheet
* Create a test site
* Add a Data View Web Part (DVWP) to the Test Site
* SharePoint Designer > Open test site > Open default.aspx
* Split View
* Menu > Insert > SharePoint Controls > Data View
* Data Source Library > XML Files > Add an XML file:

Upload the XML file from Step 5A
* Drag the content from the new data source to the DVWP
* Format the DVWP accoding to the desired look and feel for search results
* When look and feel is complete, open the XML editor and create a new XML file:
Visual Studio > File > New > File > XML File
* SharePoint Designer > Highlight the DVWP in the Design window
* Copy the code for the DVWP from the Code view
* Paste the XML into the new XML file
* Identify the XSL Stylesheet portion of the XML
* Cut away any unnecessary XML from the file, leaving only the XSL Stylesheet

* Save the XML file to be used in Step 5C

5C. Apply the new XSL Stylesheet to the Search Results Web Part
* Visual Studio > Open file:
Open the XML file created in Step 5B
* Search Center site collection > search results page > search results web part > edit web part > Modify Shared Web Part
* Web part tool pane >Miscellaneous > XSL Editor:

Open the XSL Editor
* Paste the XML from Visual Studio into the XSL Stylesheet, overwriting the existing stylesheet
* Click OK

Blog Archive

Followers