adminbackendbolt-cmscontenttype

Allow only one instance of a content type


I have created a custom content-type for the homepage in bolt. And I was wondering how to remove the "add new home" from the admin panel of bolt so that it is only possible for my client to have 1 instance of the homepage, instead being able to add multiple which would make no sense.

So essentially removing the that function that is called "New [name of contenttype] option.

I think this could be done by writing my own extension maybe but i'm not capable of doing this yet as I'm still learning.


Solution

  • Generally speaking creating a whole new contenttype for home page isn't a good idea unless you want the user to have the ability to add more of those.

    Anyways, you can restrict your user from adding more of home contenttypes through permissions.yml. As a first step, define roles e.g. superadmin is you who develops the system and admin is the user of CMS. Then for home contenttype, set create permission to superadmin:

    `create: [ superadmin ]`
    

    All of the other users won't be able to create new homes including admins.

    More on this in bolt docs: https://docs.bolt.cm/permissions#example-editors-and-chief-editors