Forum Discussion
Any way to exclude Templates folder from Highlighted Content Web Part?
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.
No reason to reinvent the wheel
- DavidWexelblatJun 07, 2023Brass Contributor
CAML, not KQL, since I'm using "The page library on this site", and that's what I did, as I noted in the post above your reply.
But I had to spend well over an hour figuring out how to make this CAML query, never having done it before (learning the syntax, discovering the "Scope" parameters, etc.), for something that shouldn't even be necessary - there's no way templates should be included in "highlighted content" when the page library is the source. It makes absolutely no sense.
And having to tailor queries is a far bigger PITA than selecting fields on the filter UI, which makes this approach problematic for page maintenance/site reuse. I'm the only one on my team who has any chance of sorting out queries at this level. My non-tech-savvy content collaborators shouldn't have to deal with this complexity for something so simple.
- Jun 07, 2023Yeah Caml query is super old school and shouldn't be used. That's why I said KQL 🙂 KQL query is a lot easier and more modern, just say path, type and what you need to exclude 🙂
- DavidWexelblatJun 08, 2023Brass ContributorWhether the query is KQL or CAML depends on which source chosen for the HCWP. Since I'm looking at "The page library on this site", CAML is what it takes. I can play around with one of the larger sources and KQL, but my base issue still holds - my collaborators have no chance of being able to deal with any query language, and it just shouldn't be needed for this use case.