CSWP is one of the features made available to SharePoint 2013 on-prem with availability on SharePoint Online closely following. This Web part uses the search results from a query and gives us the ability to load these search results and give an improved user experience for users of a publishing site. One of the primary usages of the CSWP is branding for publishing sites. As per MSDN – The Content Search Web Part (CSWP) is a Web Part introduced in SharePoint 2013 that uses various styling options to display dynamic content on SharePoint pages.
How it works
A CSWP query returns results and allows you to format the display so that it can be more meaningful for end users.
We have multiple web part properties here. Search criteria, Display Templates, Property Mapping and Settings are the specialties of this web part. The rest of the properties window is similar to other web parts.
Search criteria is where we define the search query that brings the data inside the CSWP and will eventually be presented to the end users. You can also select the number of items that the Search query should bring in.
There are different control and item templates to Present data in CSWPs which presents the data differently. “Control” is the base where you decide whether it will be a list, a list with paging, or a slider.
“Item” defines the presentation of different columns on the web part. You can also create your own Item template. I have created my own item template called “Announcements.” Please reference my other blog “Creating a new Item template for the Content Search Web Part.” There are out of the box options available as well that may fulfill your requirements.
Once you have select your desired item template, then you can change the fields that come with search items. By checking the check box “Change the mapping of managed properties for the fields in the Item Display Template,” you can change the field against each line. If you have changed the item template, then it will present different fields according to the changes in the HTML structure that you’ve defined.
Settings are pretty simple. You can select your desired query that you built for this CSWP or you leave it to the default. You can also select the tables if you are querying multiple tables. Last but not least, you can tell CSWP to display all the items or skip the first few of them. Also, you can give an alternate error message if the query returns an error.
Content Search Web Parts is one of our favorite features in SharePoint, and we can’t wait for it to be available on SharePoint Online as well. If you want to learn more about SharePoint’s capabilities or how to make customizations to web parts, feel free to reach us by submitting the contact form below.