logo

Palette - Make it Colorful🎨

Palette - Visual Page Builder, no design degree required.

Live Demo Download Palette

Scroll
13/04/2025, by Ivan

This guide continues with the Hello World module, demonstrating how to gradually add custom blocks (and more).

If you're feeling adventurous, you can jump straight to the Examples module. The Examples module contains many more code samples used in this guide. If you're new here, keep following this tutorial and check out the Examples modules when you're ready to dive deeper.

13/04/2025, by Ivan

By adding a single YAML settings file to our module, Drupal will automatically load the contents of this YAML file, and we’ll be able to access it to provide default configuration. From the root folder of your module, create a new folder called “config.” Inside that folder, create another one named “install.” Finally, inside config/install, create a new file and name it hello_world.settings.yml.

13/04/2025, by Ivan

There are two steps to creating a simple page in Drupal:

Declare the route and its parameters.

This step includes the page title, access requirements, and more.

In Drupal 7, you had to implement hook_menu().

In Drupal 8, create a <module_name>.routing.yml file in the top-level directory of your module.

Write the code that returns the page content.

In Drupal 7, you would write a page callback function specified in hook_menu().

13/04/2025, by Ivan

Unlike in Drupal 7, creating multiple instances of a block to place on your site is a simple task in Drupal 8.

This tutorial will teach you how to programmatically add a block to the block layout interface, how to add an (administrative) configuration form to the block, and how to handle it. Finally, you’ll learn how to define and display default configuration values for the form.

Before starting this step-by-step guide, prepare your module skeleton as described in “Prepare the module skeleton.”