Wednesday, June 01, 2011

Contextual Search Results

I wanted to configure a contextual search to bring back results from a particular list only and display the results on the same web part page. I also wanted to be able to open the results items in a modal dialogue box (new for SharePoint 2010). On my page I have:
  1. a Search Box web part configured as follows: 
    • Scopes dropdown: Do not show dropdown and default to target results page 
  2. a Search Core Results web part configured as follows: 
    • Results Query options / Append Text To Query - Site:http://site/Lists/ListName contentclass:STS_ListItem.
    • Edit the Display Properties XSL by searching for this line:

      <xsl:attribute name="href"> <xsl:value-of  select="$url"> </xsl:value-of></xsl:attribute>

      and replacing it with this:

      <xsl:attribute name="href"> javascript:OpenDialog('<xsl:value-of select="$url">') </xsl:value-of></xsl:attribute>
    Thanks to Glyn for pointing me in the right direction again and Rain Tree Studio for this list of contentclass values, which can be appended to a search query:

            case "STS_Web":                                       // Site
            case "STS_List_850":                                 // Page Library
            case "STS_ListItem_850":                          // Page
            case "STS_List_DocumentLibrary":            // Document Library
            case "STS_ListItem_DocumentLibrary":     // Document Library Items
            case "STS_List":                                        // Custom List
            case "STS_ListItem":                                 // Custom List Item
            case "STS_List_Links":                             // Links List
            case "STS_ListItem_Links":                      // Links List Item
            case "STS_List_Tasks":                            // Tasks List
            case "STS_ListItem_Tasks":                     // Tasks List Item
            case "STS_List_Events":                          // Events List
            case "STS_ListItem_Events":                   // Events List Item
            case "STS_List_Announcements":            // Announcements List
            case "STS_ListItem_Announcements":     // Announcements List Item
            case "STS_List_Contacts":                      // Contacts List
            case "STS_ListItem_Contacts":               // Contacts List Item
            case "STS_List_DiscussionBoard":          // Discussion List
            case "STS_ListItem_DiscussionBoard":   // Discussion List Item
            case "STS_List_IssueTracking":              // Issue Tracking List
            case "STS_ListItem_IssueTracking":       // Issue Tracking List Item
            case "STS_List_GanttTasks":                  // Project Tasks List
            case "STS_ListItem_GanttTasks":           // Project Tasks List Item
            case "STS_List_Survey":                        // Survey List
            case "STS_ListItem_Survey":                 // Survey List Item
            case "STS_List_PictureLibrary":             // Picture Library
            case "STS_ListItem_PictureLibrary":         // Picture Library Item
            case "STS_List_WebPageLibrary":             // Web Page Library
            case "STS_ListItem_WebPageLibrary":         // Web Page Library Item
            case "STS_List_XMLForm":                    // Form Library
            case "STS_ListItem_XMLForm":                // Form Library Item
            case "urn:content-class:SPSSearchQuery":    // Search Query
            case "urn:content-class:SPSListing:News":   // News Listing
            case "urn:content-class:SPSPeople":         // People
            case "urn:content-classes:SPSCategory":     // Category
            case "urn:content-classes:SPSListing":      // Listing
            case "urn:content-classes:SPSPersonListing":// Person Listing
            case "urn:content-classes:SPSTextListing":  // Text Listing
            case "urn:content-classes:SPSSiteListing":  // Site Listing
            case "urn:content-classes:SPSSiteRegistry": // Site Registry Listing

    No comments:

    Post a Comment