Modular Block get all Content in Model


First of I’d like to say that I love love love DatoCMS. Does anyone has suggestions on how I could make a Link field inside of a Content Model where I could create a Modular block that will query all records of a specific Model?

I’m trying to make a content block where in the query, it grabs all content associated with that model. I know that using links, you can select all links from a category. While that sort of works, I’d like to make this dynamic so as new records get added/removed the query is up to date.

The goal I had in mind is to get all this data so I can render it serverside in Next.js. I of course could request the content on the client, but I’m hoping to avoid that because I’d like to minimize API calls.

Does anyone have thoughts on how I could achieve this? Thanks so much

Unfortunately not at the moment. You should specify all the possible models that you can link, and update that every time that you add models.

You could automate that using our webhooks that can be triggered on model creation or deletion, if it’s something that you want to do?

Thank you so much for responding @mat_jack1!

I’ll definitely look into webhooks on model creation/deletion, maybe that’s the way to go.

Alternatively, I haven’t looked too closely into it - but do you think it’s possible to make a plugin for this purpose? Might it be possible to create a field that pulls a list of all content models?

1 Like

Unfortunately you cannot do that with plugins as they affect only records, not model creation, which is where you want to modify your behaviour.

The models that you can link are part of a validation that we enforce both on the CMS side and on the API side, so you need to modify the link validations, which means that you cannot do that via a plugin :frowning: