Retrieve reusable data with Headless channels
We currently have a project and are trying to add a headless channel. In the channel we have headless items and can add items in a list to provide to the application. Lets call it articles. Can we directly access Reusable content items from a headless channel or do we always have to manually include them in some sort of list.
If we add a new article I would like them to be directly available on the headless channel without having to manually configure this. Would this be possible? Or is it only possible to collect the data from headless items?
Environment
- Xperience by Kentico version: [28.4.0]
- .NET version: [8]
- Deployment environment: [SaaS|Azure]
- We followed the following documentation Retrieve headless content
Answers
@Danny-Paul
The answer to this question is easiest to explain by looking at the other channel types.
If you want to expose a reusable content item over a website or email channel, can you just "expose it"?
Nope! You need to create a web page or email to deliver that reusable content item through in that channel. This is intentional.
Headless channels work the same way. You need to create a headless item that exposes the reusable content.
Headless channels are not meant to be a tunnel into the database for developers. Instead, they are meant to give marketers complete control over what content is exposed through the channel.
All that said... yes, today headless channels are not flexible enough to expose a "set" of reusable content items and instead they much each be explicitly selected.
However, we have a planned way to resolve this issue. Smart folders, which we will be delivering soon, will allow marketers to create dynamic sets of content and then select the smart folder as the source of related content for a headless item's related content field.
In the meantime, I recommend creating a global event handler that updates a headless item's related content items every time a new article is published.
You might be able to find inspiration in the Community Portal source code 👍.
To answer this question, you have to login first.