Sitecore can show search results in the following different views: ID, Image, Lock, Media, Preview, Table, and Tag view. You can add new views if these views do not fit your needs.
This topic outlines how to:
Add a new search result view
To add a new view:
- Navigate to
/sitecore/system/Settings/Buckets/Viewsand in the Views folder, create a new view item.
- In the Header Template, Item Template, and Footer Template fields, specify placeholders and HTML tags to format the search result:
You can use the following built-in placeholder names to display item values in the search result:
The CSS style that you want to use when the results are displayed.
Specifies the result is launched in a new tab or in a new Content Editor window.
The item ID.
The path to the image of the item.
The name of the item.
The name of the template that the item is based on.
The bucket that this result comes from.
The content of the result.
The version of the content item.
The date that the content item was created.
The person who created this item.
Show a dynamic field in a search result view
You show dynamic fields in search result views by specifying the field in the
buckets.dynamicFields pipeline. For example, if you want to display Facebook likes for a specific item you can use this pipeline to display this information in the search results.
buckets.dynamicFields pipeline aggregates a dictionary of keys and values. To obtain the information you want, you must refer to the relevant key and value in the dictionary. In the Facebook example, the key is
Flikes and the value is the number of likes specified by the Facebook API.
To display a dynamic field in a specific search view:
- In the content tree, navigate to
/sitecore/system/Settings/Bucketsand in the Views folder, select the search view.
- On the Content tab, in the View Details section, click the Item Template field.
This field contains the HTML output for the search view.
- To insert the placeholder, enter the relevant key followed by
For example, if the key for Facebook likes is
Flikesin the dictionary, the placeholder is:
When Sitecore displays the search results, it looks at all the dynamic placeholders and replaces them with the value of each specific key.