Forum Discussion
DavidWexelblat
Jun 02, 2023Brass Contributor
Any way to exclude Templates folder from Highlighted Content Web Part?
I am trying to figure out a way to exclude pages under "Site Pages/Templates" from the Highlighted Content Web Part (Source = "The page library on this site"). Using a static metadata column doesn't ...
DavidWexelblat
Jun 06, 2023Brass Contributor
SvenSieverding - I played around with that JSON formatting, and it's way beyond me. That example didn't work as is (I know parts of it are looking for specific fields, but I didn't even get any thumbnail images in my grid, and got completely lost trying to figure that out).
I decided to try doing a calculated field to look for a specific tag in the page title, which was easy to do - but HCWP doesn't show the calculated field as a "page attribute" for filtering, only title and a couple of choice fields I set up as page metadata. Sigh.
So I came up with another solution - using a CAML query with "Scope='FilesOnly'" on the <View> tag. CAML doesn't traverse folders by default, and this keeps the "Templates" folder itself from showing up in the results.
It works, but I'm not a fan of needing to build CAML queries for what should be simple stuff. Makes page maintenance and reuse far more hassle than it should be.
I decided to try doing a calculated field to look for a specific tag in the page title, which was easy to do - but HCWP doesn't show the calculated field as a "page attribute" for filtering, only title and a couple of choice fields I set up as page metadata. Sigh.
So I came up with another solution - using a CAML query with "Scope='FilesOnly'" on the <View> tag. CAML doesn't traverse folders by default, and this keeps the "Templates" folder itself from showing up in the results.
It works, but I'm not a fan of needing to build CAML queries for what should be simple stuff. Makes page maintenance and reuse far more hassle than it should be.
Jun 06, 2023
Just use KQL in the highlighted webpart and add what you want to display in the kql and add"-path:{Full Path}*" to exclude everything within a certain path.
No reason to reinvent the wheel
No reason to reinvent the wheel