'Strapi Hide Content Type

I've search for several hours how to hide a specific content type.

I found some post but they are too older and their solutions doesn't work in the actual's strapi.

For precisions, my collection type is declared inside a local plugin. I juste want to manage my collection inside the plugin page and I doesn't want it appear in the content type in the left menu.

If someone has a solution, it's can be really helpfull.



Solution 1:[1]

They are working on this: https://github.com/strapi/rfcs/pull/22

But for now, based on official docs (plugin customization), you can overwrite file in content-manager plugin.

Be sure to check this file on strapi updates to avoid overwriting important code.

  1. Copy file strapi-plugin-content-manager/services/data-mapper.js from your app node_modules into extensions/content-manager/services/

  2. Now edit this file in your project and add your content type to array HIDDEN_CONTENT_TYPES following this pattern: plugins::[plugin-name].[content-type] For example: plugins::ecommerce.product

...

const HIDDEN_CONTENT_TYPES = [
  'plugins::upload.file',
  'plugins::users-permissions.permission',
  'plugins::users-permissions.role',
  'plugins::ecommerce.product',
];

...

Solution 2:[2]

In new version of Strapi v3.6.6 — Community Edition there is an option in model

{
  "kind": "collectionType",
  "collectionName": "test",
  "info": {
    "name": "test"
  },

  "options": {
    "increments": true,
    "timestamps": true,
    "draftAndPublish": true
  },

  **"pluginOptions": {
    "content-manager": {
      "visible": false
    }
  },**

  "attributes": {
    "name": {
      "type": "string",
      "required": true
    },
    
  }

}

Solution 3:[3]

You can extend the plugin to make updates to the content-type's schema.

Copy the content-type schema from the plugin to your src folder.

In my case, I copied /strapi-plugin-navigation/server/content-types/audience/schema.json to /src/extensions/navigation/content-types/audience/schema.json (notice that the strapi-plugin- part of the folder name is removed) and added the following to it to hide the "Audience" content type from the content manager and content-type builder:

"pluginOptions": {
   "content-manager": {
     "visible": false
   },
   "content-type-builder": {
     "visible": false
   }
},

Official documentation here.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2
Solution 3 Shakti