Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

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

default discord avatar
mrl72 years ago
4

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
    markatomniux2 years 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
    mrl72 years ago

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

  • discord user avatar
    jarrod_not_jared
    2 years 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.

  • default discord avatar
    carolinda12455 months ago

    I am trying to implement something similar.



    I have a Header global config, but I have some variations to be setted on page level (local).


    For example: for a specific page I want the Header to have other color and an extra button.



    I have created the local configuration as block (there are other settings that should operate similarly), but it shouldn't be able to be included in that page more than once. Is there a way around it?

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.