0

I have a SPO site with modern pages. I've given the pages some extra metadata and am using the Page Properties webpart.

I'm trying to use the Highlighted content webpart to show content specifically related to the current page.

For example, if the current page is about our Oregon service region I want to show documents from a library (on the same site) which have Oregon as a keyword.

I can do this if I open the highlighted content webpart settings and manually enter Oregon in the filter and sort settings, but I have a lot of pages to do and that is likely to result in typos and mistakes.

I'm trying to find a way to access the page properties and have that dynamically inserted into the filter.

I don't have to use the highlighted content webpart. I also tried the PnP Modern Search webpart. There is a setting in one of the configuration panels for the web part that lets you create a dynamic search query connected to the "Page environment, but I can't figure out how to use that. There is no option to actually select data associated with the page, so I'm thinking "page environment" means something else.

Enhanced search web part configuration panel

Is there a way to dynamically filter content on a page so that it relates to the page?

1 Answer 1

1

You can achieve it using PnP Search. You can use Page Token where you can configure query according to current page property values.

You can configure search query as below:

{YourManagedPropertyName}:{Page.[InternalNameOfField]}

E.g. Let say you have managed metadata column with internal name TESTDepartment and you have added same column in Site Pages and Document Library then your query should look like shown in below screen shot: (In my case I do have managed metadata column hence I am using {Page.TESTDepartment.TermID} but in your case if you do have normal text or choice column then you can use it like {Page.TESTDepartment} without TermID)

enter image description here

Document Library Content:

enter image description here

Site Pages Library:

enter image description here

You need to create managed property for your field which you want to filter. You can follow this link to do so. In my case managed property look like as below:

enter image description here

After creating managed property, if you don't get result immediately then please wait for some time for crawl.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.