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

default discord avatar
9 months 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.

  • default discord avatar
    Mark | Omniux
    9 months 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

  • default discord avatar
    9 months ago

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

  • default discord avatar
    9 months 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
Like what we're doing?
Star us on GitHub!


Connect with the Payload Community on Discord



Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.