Return to the root folder of your module where the .info.yml file is located, add a new file named hello_world.routing.yml, and add the following content to it:
Now that we've created a placeholder for our module's settings page, let's add a menu link. The instructions below show how to create a menu link for the hello_world module under the “Development” section on the “Admin > Configuration” page (http://example.com/admin/config).
In the root folder of your module, create a new file named hello_world.links.menu.yml and add the following:
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.
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.
Introduction
Much has been said—and debated—about the latest version of Drupal—Drupal 8, and one thing is certain: the way modules are built has changed significantly. There are numerous tutorials addressing the new concepts, and many of them encourage developers to stay updated as the codebase evolves.
Introduction
Much has been said—and debated—about the latest version of Drupal—Drupal 8, and one thing is certain: building modules has changed significantly. There are many tutorials focusing on the new concepts, and in each one, the authors advise developers to expect even more changes as the codebase evolves.
Part II of the Practical Guide to Creating Basic Drupal 8 Modules
From .info to Tests, Just the Basics
Part IV of the Practical Guide to Creating Basic Drupal 8 Modules
From .info to Tests, Just the Basics
So far, everything is pretty tidy, but how can we change what we see? With some forms, of course.
Main Topic: Defining Your Own Configuration
You can include default configuration in your module based on the functionality of other modules (content types, views, fields, text formats, etc.).
For example, the Node module provides a content type configuration, so in your own module, you define a default content type that can be shipped with your module.
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().