Use the following command to run the included util for creating a new content type:
cd /var/www/_scripts/utils && ./create_drupal_content_type.sh
The following example will show you how we create the Basic Page (basic_page) content type:
What is the userfriendly name of the Content Type?
Content Type name: Basic Page
Fill in a userfriendly description?
Description: Basic Page
Would like the custom module to have a install file (yes/NO)?
install file: no
Would like the custom module to have a libraries file (yes/NO)?
no
Would like the custom module to have a permissions file (yes/NO)?
no
Would like the custom module to have a event subscriber file (yes/NO)?
no
Would like the custom module to have a block plugin file (yes/NO)?
no
Would like the custom module to have a controller file (yes/NO)?
no
Would like the custom module to have a settings form file (yes/NO)?
no
Creating a Drupal module and a Content type named 'Basic Page'.
Create 'cms/modules/project' directory!
Welcome to d8:module:standard generator!
––––––––––––––––––––––––––––––––––––––––––
The following directories and files have been created or updated:
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
• basic_page/basic_page.info.yml
• basic_page/basic_page.module
Do some renaming magic
Got to: /var/www/public/cms
Enable Drupal module 'basic_page'
[success] Successfully enabled: basic_page
Clear Drupal caches
[success] Cache rebuild complete.
Adding Drupal module to Git
Success!!
After this the content type should appear on the dashboard:
It has also created and enabled a Drupal Module that allows content to also save to MongoDB:
Additional Drupal Content Type Documentation: https://www.drupal.org/docs/7/understanding-drupal/content-types
Last modified | Friday, April 30, 2021, 12:00:21 PM UTC |
Last author | Colin van Eenige |
Commit ID | 4c7a701 |