We need to create a Block for our Structured Text which will display the 3 last News (Model).
In the Block, we would have a Field “latest_news” (type Links): to allow 3 items of type News. Is it possible to auto-fill this field so that the user hasn’t to update it each time manually will the latest news?
For our server-rendering, it would be necessary that these 3 latest news are directly delivered through the API within Block content, in the Structured Text. Much likely as it would if the user would choose the links manually.
Is there any strategy for doing such a thing?
Thanks a lot for your help
Is there any reason to put the 3 latest News items into blocks to begin with? Via the GraphQL API, you can already fetch the latest 3 items of that model using the orderBy: _publishedAt_DESC and first: 3 parameters.
The frontend query that anywhere it needs to, without your editors having to manually edit anything at all (except posting news stories, of course).
In the structured text, I’d probably just make a “dummy” block, and then the frontend could use a custom block renderer to do the fetching and rendering of the latest 3 news items.
Would that work?
I think it would be difficult to get that working otherwise. We can leave the feature request here, but because it’s not a common request, it might not get implemented in a reasonable time
You might be able to shim something up with our plugins SDK and webhooks, but it would be a lot of work for really no gain over just having the frontend do it via the GraphQL API.
Hi Roger,
Thanks for your quick answer. Yes, we already thought about this kind of solution, where we fetch the 3 last items on the layout and store them, or where we do the fetching directly inside of “dummy block”. We wanted to avoid that for performance reasons, to only have one fetch for this data.
We found another solution, where this block isn’t in the structured text anymore. I understand this is a special edgecase, you can close the request! Thanks!