Module development

Create a content type programatically Drupal 8

​Basic creation of a content type in Drupal 8. Content type is created in code in a custom module called dribbit_create_content_type.

module_directory_node.png

As seen on the left, an install directory located in the config directory is needed to store the content types yaml file. Human readable data is used to preconfigure the content types settings.

Create a block programatically in Drupal 8

​​block_example.PNG

Basic creation of a block in Drupal 8. As seen in the image on the left, a predefined library structure is needed to create a block plugin.

The annotations plugin is used to handle the block id, subject and admin label from within the comment block. The annotation class is found at core/lib/Drupal/Component/Annotation/Plugin.php.

Subscribe to RSS - Module development