Filtering SharePoint News Pages with Metadata
This is a quick tip about a SNAFU which caught me up today. I got to do a “Doh!” in front of a client, which is always fun. Hopefully this will save you the same embarrassment.
Filtering News pages based on some metadata applied to the pages is a thing, and has been for a good, long time. I knew it should work, and pretty easily at that.
When I was on the call, I had added a metadata column to the Site Pages library. Simple. I went and put the page with the News Web Part into edit mode and looked in the Filter section for Page properties. No joy. Instead I was seeing:
Managed Properties are awesome, and I set them up all the time so I can build search-driven solutions, usually with the PnP Modern Search Web Parts, which, as I’ve said before, are the bees knees. But I knew there should be an option to filter based on Page properties instead. Had something changed? Was it better? I wasn’t sure.
I fired up my MVP communication channel and asked if things had indeed changed. As I expected, Susan Hanley (@susanhanley) responded almost right away.
Look to see what the Source is for News. When it is a single site (i.e., the site you are on), you can filter using Page properties. When you are selecting news from multiple sites, you will not see the Page Properties option – just Managed property.
Doh! I hadn’t even though to check that setting! A simple change at the top of the News Web Part properties to use This site as the source, and Page properties was back where I expected it.
This makes sense if you think about it. The Page properties in Site Pages libraries probably wouldn’t be consistent across multiple sites, so Managed properties makes more sense. Within one site, the Site Pages library is a single source, so has to be consistent with itself.
I do think there could be some in-Web-Part assistance for this with a slightly better UI, though. Maybe just an info bubble like the Enable audience targeting section right below it?
As you might expect, Greg Zelfond (@gregoryzelfond) has a great post about all this if you want to understand it better:
How to manage categories of news using custom metadata – SharePoint Maven
Hi Marc,
I’m trying to use the Managed property where ContentType = Repost Page but no matter what I enter in the ‘Enter search value’ the webpart does not limit the content shown. How do I use the Managed property ContentType for limiting news?
@Mike:
It probably depends where and how you are trying to use that filter. I’d probably try this:
SPContentType:’Repost Page’
M.
I’m still shocked that the Page Properties web part (which displays the property tags you’ve added to a given news/page item, doesn’t actually do anything. Meaning, you see the tags for that news item, but it looks and behaves like a button, but doesn’t actually launch anything. I was expecting it to perhaps take me to a built-in all news pages, dynamically filtered on the tag property I clicked on. Nope.
In fact, there doesn’t seem to be a way to create that experience at all. Do you know of way to accomplish that?
Jim:
Yes, that Web Part is pretty rudimentary. That’s an excellent idea for an enhancement.
You could create your own custom Web Part using the SharePoint Framework. I don’t think there’s a sample that does this, but check out https://pnp.github.io/sp-dev-fx-webparts/ for ideas and/or starting points.
M.
Thanks for the response.
I thought about a custom SPFx webpart too, but the second problem I ran into is that there doesn’t appear to be any support for the existing news or highlighted content webparts to support displaying content filtered by URL parameter. That would be key to building the dynamic behavior of showing news article results by page property. Perhaps the PNP search results web part would support that–not sure.
Yes, you can use query string values with the PnP Modern Search Web Parts: https://microsoft-search.github.io/pnp-modern-search/usage/search-results/tokens/#context-tokens
It would depend on the scope and how you’d like the results to be displayed.