News Card¶
Follow these steps to set up this tile in PnP Modern Search Results.
1. Add the Search Results Web Part¶
Add the PnP Modern Search Results Web Part to your page.
If you are unsure how to add a web part, Microsoft documenation details this here:
Using web parts on SharePoint pages
For additional information regarding PnP Modern Search Results, please consult the PnPModernSearch documentation:
Using PnPModernSearch Search Results Web Part
2. Set up your initial query¶
In page 1 of the Property Pane, set your initial query in the Search query keywords box. Here you may also connect the web part to a Search Box web part.
To display news you must include PromotedState:2
in your KQL query.
To display documents from a document library you must include *
in your KQL query.
3. Set Query Template¶
On page 2 in the Query Template use the search term Path:{Site.URL}
so you can display news from your local site.
To view other Query Template samples, click here to see some example queries.
4. Set Selected Properties¶
On page 2 of the Property Pane, though there is a default selection of properties please make sure to add any requiered Properties or Mercury specific Properties via the Dropdown List
Properties:
AuthorOWSUSER,
ContentTypeId,
Created,
CreatedBy,
Description,
EditorOWSUSER,
LikeCount,
MercuryArticleDateOWSDATE,
ModifiedOWSDATE,
MercuryContentType,
owstaxIdMercuryBusinessUnit,
owstaxIdMercuryCategory,
owstaxIdMercuryDepartment,
owstaxIdMercuryTypeOfContent,
PictureThumbnailURL,
SiteID,
SPWebUrl,
Title,
UniqueID,
ViewsLifeTime,
WebId
If you are including Classic Publishing Pages in the search results tiles, include the following property, so that the page image appears in the preview:
PublishingPageImageOWSIMGEX
For Documents also include:
FileExtension,
FileType,
MDCListTitle,
MDCPublishedByUserOWSUSER,
MDCTitleOWSTEXT,
ModifiedBy,
owstaxIdMDCDocumentType
For Events, also include:
BannerUrlOWSURLH,
ContentTypeId,
EventsRollUpCategory,
EventsRollUpEndDate,
EventsRollUpStartDate,
ListID,
ListItemID,
Location,
People
For Videos, also include:
SitePath
LastModifiedTime
Note
You may have to have already created News Articles or other types of content already tagged with the fields that start with "owstaxId", e.g. Mercury Business Unit, Department & Category. These already existing News Articles will have to be Published and Promoted as News prior to being available to select.
5. Set up Result Types¶
On page 3 of the Property Pane, set the Results layout to "Custom".
5. Set Group Level Template¶
On page 3 of the Property Pane, add the requiered Group Level Display Template to "Use an external template URL".
The correct template is:
https://cdn.mercuryintranet.com/modern-mercury-searchtemplates/group/ResponsiveTemplate.html
NOTE: These are case sensitive.
More information on Group Templates can be discovered here:
6. Edit Result Types¶
On page 3 of the Property Pane, select "Edit Result Types".
This panel allows you to edit Result Types and the HBS templates which render for each result.
Configuring Result Types may vary on needs, however since this template is intended for News pages we shall use that as an example. In previous steps we would have created a query to return the relevant items, e.g. "PromotedState:2".
We can now target all pages returned with that value by using the following setting:
Setting | Value |
---|---|
Managed Property | ContentTypeId |
Operator | Contains |
Condition Value | 0x01 |
Inline Template | DO NOT EDIT |
External Template URL | https://cdn.mercuryintranet.com/modern-mercury-searchtemplates/item/NewsCardTC.html |
NOTE: If an invalid URL is entered you will be warned.
Once this (and any additional item specific templates) have been set select the "Save" button, you have now configered this template.