Working with the Search Results Web Part
You use the Search Results Web Part to display search results from a single search provider. The Web Part has two configurable tabbed views. The tabbed view can display either the catalog search results or the site content search results. If you are using Microsoft SharePoint Foundation 2010, you need to install SharePoint Search Server for site content search. If you are using SharePoint Server 2010, then search service is included.
Architecture
The Web Part has two tabs for different types of search results: Product Catalog and Site Content. You must associate the Search Results Web Part control with a Search Provider Web Part, and set a property in the Search Results Web Part that determines which provider's search results to display. Multiple instances of the Search Results Web Part can exist on the same page, and may have their search provider (Commerce Server 2009 R2 or SharePoint) independently configured.
Properties
Name |
Maps to |
Description |
Type |
Default value |
---|---|---|---|---|
Category to search |
ProductCategory |
String |
Sets the name of the product category that will be searched if the setting "Phase to search" is not empty. |
Blank |
(Tab 1) Content type |
TabOneContentType |
Enum |
Sets the content type that will be displayed by this tab. |
ProductCatalog |
(Tab 1) # of results per page |
TabOneResultsPerPage |
Int |
Sets the number of results to display per page. |
10 |
(Tab 1) Properties to retrieve |
TabOneRequiredProperties |
String |
Sets a semi-colon ';' separated list of Commerce Foundation "Product" properties that will be retrieved as the result of the search. |
Id;DisplayName;Description;ListPrice;Image_filename;CatalogI d; |
(Tab 1) Sorting Properties |
TabOneSortingProperties |
String |
Specifies the available sorting options using a custom XML-based configuration. |
<SortOptionItems> <SortOption Name="ListPriceDesc" DataItem="ListPrice" AscOrder="false" DisplayText="List Price (Highest to lowest)"/> <SortOption Name="ListPriceAsc" DataItem="ListPrice" AscOrder="true" DisplayText="List Price (Lowest to highest)" /> <SortOption Name="DisplayName" DataItem="DisplayName" AscOrder="true" DisplayText="Product Name" /> </SortOptionItems> |
(Tab 1) Query filter |
TabOneQueryFilter |
String |
Sets an SQL-like "Where" clause that will filter results. |
Blank |
(Tab 1) Default sorting property |
TabOneSortBy |
String |
Sets the name of the property to use when sorting displayed results. |
ListPrice |
(Tab 2) Content type |
TabTwoContentType |
Enum |
Sets the content type that will be displayed by this tab. |
SiteContent |
(Tab 2) # of results per page |
TabTwoSortBy |
Int |
Sets the number of results to display per page. |
10 |
(Tab 2) Properties to retrieve |
TabTwoRequiredProperties |
String |
Sets a semi-colon ';' separated list of Commerce Foundation "Product" properties that will be retrieved as the result of the search. |
workid;rank;title;size;path;description;write;sitename;collapsingstatus;hithighlightedsummary;hithighlightedproperties;contentclass;isdocument |
(Tab 2) Sorting properties |
TabTwoRequiredProperties |
String |
Specifies the available sorting options using a custom XML-based configuration. |
<SortOptionItems> <SortOption Name="Rank" DataItem="rank" AscOrder="true" DisplayText="By Relevance"/> <SortOption Name="write" DataItem="write" AscOrder="true" DisplayText="Last Updated Date" /> </SortOptionItems |
(Tab 2) Query filter |
TabTwoQueryFilter |
String |
Sets an SQL-like "Where" clause that will filter results. |
Blank |
(Tab 2) Default sorting property |
TabTwoSortBy |
String |
Sets the name of the property to use when sorting displayed results. |
rank |
"No results" XSL template |
NoRecordsFoundTemplate |
String |
Sets the path of the XSL template used to generate the HTML markup when no results are returned by the search. |
DefaultSite_GeneralNotFound |
"No records found" text |
GeneralNoRecordsFoundText |
String |
Sets the text displayed when the search returns no results. |
No Records Found For Your Search |
(Tab 1) Template |
TabOneTemplate |
String |
Sets the path of the XSL template used to generate the HTML markup. |
DefaultSite_ProductCatalog |
(Tab 1) "Active" indicator image URL |
TabOneActiveImageUrl |
String |
Sets the file URL for the image that will be used to indicate that the tab is "active". |
Blank |
(Tab 1) "Inactive" indicator image URL |
TabOneInactiveImageUrl |
String |
Sets the file URL for the image that will be used to indicate that the tab is "inactive". |
Blank |
(Tab 1) Tab display name |
TabOneHeaderText |
String |
Sets the text displayed as the tab's name. |
Products Search Results |
(Tab 1) "No results found" text |
TabOneNoRecordsFoundText |
String |
Sets the text displayed when no results are found. |
No Products Found For Your Search |
(Tab 2) Template |
TabTwoTemplate |
String |
Sets the path of the XSL template used to generate the HTML markup. |
DefaultSite_SiteContent |
(Tab 2) "Active" indicator image URL |
TabTwoActiveImageUrl |
String |
Sets the file URL for the image that will be used to indicate that the tab is "active". |
Blank |
(Tab 2) "Inactive" indicator image URL |
TabTwoInactiveImageUrl |
String |
Sets the file URL for the image that will be used to indicate that the tab is "inactive". |
Blank |
(Tab 2) Tab display name |
TabTwoHeaderText |
String |
Sets the text displayed as the tab's name. |
Site Content Search Results |
(Tab 2) "No results found" |
TabTwoNoRecordsFoundText |
String |
Sets the text displayed when no results are found. |
No Site Contents Found For Your Search |
Entire site search text |
EntireSiteText |
String |
Sets the text displayed as an option in the drop-down menu that indicates all catalogs will be searched. This value must match the same property in the Search Box Web part. |
Entire Site |
SharePoint Site Search Target URL |
SPSiteUrl |
String |
Sets the URL of the SharePoint site that will be used as context when performing the SharePoint site content search. This is usually the root URL of the current site. |
Site address |
Phrase to search |
SearchingKeyword |
String |
Sets the phrase to search. Setting this field causes this Web Part to ignore search parameters, always searching using this phrase and the value of "Category to search" instead. |
Blank |
Sharepoint search scopes |
Scopes |
String |
Sets the SharePoint 2010 search scopes to use. This must be a semi-colon ";" separated list of recognized SharePoint 2010 scopes. For more information, see https://go.microsoft.com/fwlink/?LinkId=215496. |
Blank |
"Category Id" URL parameter |
CategoryIdUrlKey |
String |
Sets the category parameter name in the URL query string. This value must match the same property in the Search Box Web part. |
Category |
"Catalog" URL parameter |
CatalogUrlKey |
String |
Sets the catalog parameter name in the URL query string. This value must match the same property in the Search Box Web part. |
Cat |
Customization
You can customize the Search Results Web Part by using XSLT transformations and Web Part parameters. All default XSL templates are in the SharePoint list of templates.
Configuration can be done through the Web Part's custom editor part, called XsltTemplateEditorPart. This part is accessed through the Modify Web Part selection on the Edit menu of the Web Part when logged in as an administrator to the site.
Clicking the ellipsis button (…) for the XSL transform displays an editor that lets you edit the XSL transform directly.
The following table lists the XSLT parameters that you can use to create your template.
XSLT Parameter |
Description |
---|---|
_defaultImagesRepository |
Default location of the image repository |
HomeUrl |
URL of the site home page. |
ShowNoResultsMessage |
This boolean is used to determine whether to render the "NoResults" section of the template if no results are returned. |
OtherResultsCount |
The number of results on the other tab of the Search Results Web Part. |
NoResults |
If there are no results on either tab, then the text that has been specified as the GeneralResultsNotFound is broken into ‘elements’ and assigned to NoResults, and NoResults1-4. If results are found on the other tab but not the current tab, it does the same as above but with the ResultsNotFound text for the current tab. The string elements in the ‘not found’ templates should be delimited by a semi-colon. and NoResults1-4 will be empty. Otherwise, NoResults1-4 will contain search hints or suggestions. If ShowNoResultsMessage is true and search returns no results, the Web Part will render the text assigned to NoResults as a paragraph and then render the NoResults1 to NoResults4 statements as a bulleted list (maximum four statements). |
CurrentPath |
Query string parameter for the suggested spelling |
SpellingSuggestion |
A link to a search of the spelling suggestion |
NoResults1 |
First bulleted statement. |
NoResults2 |
Second bulleted statement. |
NoResults3 |
Third bulleted statement. |
NoResults4 |
Forth bulleted statement. |
To add custom XSLT parameters, use the Extensibility Kit to modify the Web Part.
Error Handling
There is no design-time error handling required for this Web Part.
API Dependencies
This Web Part uses the Microsoft Multi-Channel Commerce Foundation Search API.
See Also
Other Resources
Developing with SharePoint Commerce Services