Help with query pages linked to content items filtering by taxonomy

2025/02/26 7:20 PM

I'm trying to write a paged query that queries all 'ArticlePage' in the /Articles path in the content tree where the ArticlePage type is linked to a ArticleContent reusable content type and limited by a ArticleContentType Taxonomy.

Where I am stuck is that I first need to query the ArticleContent to get a list of ContentItemIDs to pass into the Linking method. However, even if I limit this just to the ID column it will still retrieve thousands of records making it inefficient. If I try to use the page size to limit the results of the query on the ArticleContent, then it is possible to get a result set that is less than the page size because whilst the Content Item is published the actually ArticlePage is not published.

I looked at the Community Portal (https://github.com/Kentico/community-portal/blob/main/src/Kentico.Community.Portal.Web/Features/Blog/Operations/BlogPostsByTaxonomyQuery.cs) as a basis.

Answers

2025/02/27 12:55 AM
Answer

While you might be able to use the content retrieval APIs to author a query for your requirements, it's going to be a stretch. You have a couple of alternatives.

  1. Consolidate your ArticleContent and ArticlePage into the ArticlePage content type. Before we had the combined content selector it was not possible to reusable web page content in email or headless channels, or across different website channels. This forced the separation of the reusable part from the web page part - that's no longer necessary. I'm actually in the preparation phase of this for the Kentico Community Portal. Eventually the BlogPostContent content type will be obsolete since I can use the BlogPostPage everywhere I need now.
  2. Write raw SQL. Sometimes this is the best option when you have more advanced scenarios. The Kentico Community Portal has a couple examples of using raw SQL by itself and also combining it with the Object Query APIs.
  3. Use a search index. Normalizing your data into a search index that supports faceted searching can give you more powerful querying abilities at the cost of the complexity of eventually consistent search indexes and additional technology. The Kentico Community Portal uses Xperience's Lucene integration to retrieve content for normal search experiences and member profiles.
  4. Give us some feedback on the product roadmap and explain the content and querying scenario you need support for.

To answer this question, you have to login first.