Is there a good way to model out multi tenant functionality within Payload? I was thinking having a sites collection that is used to create relationships between different media and blogs that would be on that site. Then I could have collections for the header, footer, pages, ect... for each site?
Is this the most sound way or is there a better way?
I am thinking the same thing, is their any hook for seeding the data to Payload for each site when installed a theme like as in wordpress?
A starting point can be
https://github.com/payloadcms/access-control-demo.gitPayload can absolutely be used for multi-tenancy. @martin.rahbek is exactly right in that this is achieved via access control. For example, you might have an "organizations" collection to represent your tenants, then you restrict access based on those organizations.
@blupandaman This vid is might also be useful for you
https://www.youtube.com/watch?v=DoPLyXG26DgOk that makes sense. Thank you
@jarrod69420 @jacobsfletch
I'm looking to give users the ability to publish posts to multiple different blogs at a time. Would a good strategy be making a global called create multi post that allows a user to post the same content to multiple sites?
With multi-tenancy you could add a
hasMany
relationship field to your
posts
collection and select each site(s) that the content belongs to. This way you only have to manage one document instead of many.
Ok makes sense. Would there be an easy way to create separate posts for each site? Just in case one site needs some info changed rather than all the sites?
Would that br a job for the beforeChange hook?
In that case they should be separate posts entirely and you should just use the built-in duplicate feature. The relationship field would still be needed, you just select one site, and not both.
I honestly didn't see that duplicate button until now! Thank you
We now have an official multi-tenant example! Check it out:
https://github.com/payloadcms/payload/tree/master/examples/multi-tenantThanks for the update!
Will check it out
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.