Like what we’re doing? Star us on GitHub!

Can we only allow one instance of a block to be selected?

3 weeks ago

I have for example a footer block which if specified on a page, it will show the footer on the website.

Is there a way to stop the CMS user from adding multiple footer blocks to the page?

I know I can set min and max rows to 1, however there are also other blocks that they could add other than the footer, so we can't use these fields.

  • Mark | Omniux
    3 weeks ago

    Have you thought about using Footers as a Global Type instead? Then in the page collection you could create a toggle that opts in to show or hide the footer

  • MRL
    3 weeks ago

    I haven’t, no. But will look into it.

  • Jarrod
    Payload Team
    3 weeks ago

    Yep, a global is the way to go here. Fetch the global data on the front end and render the footer with it. If you only want it on certain pages you could add a checkbox to your pages and check to see if the page should render the footer - this will take some extra legwork on your frontend side to do but totally possible.

Open the post
Continue the discussion in Discord
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More