Forum Discussion
Sharepoint news from different sites with filter functionality
Hi unimportant ,
on the contrary, I would use the "PnP Modern Search" webparts in this case.
https://microsoft-search.github.io/pnp-modern-search/You can use the SharePoint Search to find all news articles from different sites.
Just search for
PromotedState=2If you want to find all news from all sites (News and only news have a property "Promoted State" with a value of 2)
or if you want to search news of the sites "site1" and "site2"
PromotedState=2 (path:https://<tenant>.sharepoint.com/sites/<site1>/ OR path:https://<tenant>.sharepoint.com/sites/<site1>/)or if you want to find news from all sites in a specific hubsite.
PromotedState=2 DepartmentID:<Guid of your Hubsite>
Then configure and connect a "Search Filters" webpart with your "Search Results" webpart and define the filters/refiners you want to enable your users to search with.
You can use all properties that are defined as "refinable" in the search schema (see here: https://learn.microsoft.com/en-us/sharepoint/technical-reference/crawled-and-managed-properties-overview )
If you have custom news properties on your sites then it is a little bit more complicated. In that case you might have to map your custom properties on every site to one of the default "RefinableStringXXX" managed properties (using https://<tenant>.sharepoint.com/sites/<yoursite>/_layouts/15/listmanagedproperties.aspx?level=sitecol ). Then re-index the "SitePages" library.
After that you can search for "RefinableStringXXX:YourValue" to filter search results by your value.
If you don't want to use the PnP Search Webparts then you also can do this using the "Highlighted Contents" Webpart.
Switch it to "Custom Query" and enter the query in the "Query text (KQL)" field.
But you are not able the add dynamic refiners to the search results of that webpart. But you can use that to have some pages with pre-configured filters.
Best Regards,
Sven