
In this article we will understand how fields in Drupal work, why they are needed and how fields help to quickly develop sites in Drupal.
We have already worked with fields in previous articles:
Very often access to 3rd party services must be different on dev and live instans. In order to do this with the help of configurations, you need to use the Configuration Split module:
https://www.drupal.org/project/config_split
After you enable the Config Split module, you will be able to specify the folders for the instances. Let's go to the Configuration Split settings page of the Configuration module:
/admin/config/development/configuration/config-split
When you import a configuration from one site to another, some configurations are needed to output content, but the configuration content itself does not contain any. In this tutorial, we will explain how to transfer blocks, nodes and taxonomy terms from one site to another.
Configuration in Drupal is the basis for all settings of content types, fields, configuration forms and variables. With the help of configuration we can transfer changes from one site to another, develop different features at the same time and without interfering with each other.
Configurations can be uploaded to YML files and added to the Git repository, so you can commit your changes in site settings and transfer the changes to Dev or Live. The idea of configuration in Drupal is similar to how the Features module works:
In this article we will continue to understand Form API in Drupal 8 and make a multistep form. We have already created the usual configuration form for the module, the multistep form is created in a similar way using $form_state to store data between the form steps.
Examples of code can be found at github:
https://github.com/levmyshkin/drupalbook8
For a multistep form you need to add a form class:
/modules/custom/drupalbook/src/Form/MultiStepForm.php
In one of the previous lessons we have learned what hooks are, in this lesson we will work with hook_form_alter() hooks in practice and add functionality to the existing form.
Examples of code can be found at github:
https://github.com/levmyshkin/drupalbook8
In this lesson we will start to look at hooks in practice, later on we will return to hooks and look at a couple of other examples. For now, let's start with hook_form_alter().
In this tutorial, we will deal with the Drupal Form API and create a settings form for the module. We have already created modules for displaying the page and block, let's now create a configuration form in which we will store data for connecting to a conditional service. Let's say that we need to store the API Key and the API Client ID on the site, for example, for the Google Maps API.
Code examples can be viewed on github:
https://github.com/levmyshkin/drupalbook8
In this tutorial, we will look at how to output blocks programmatically through a custom module in Drupal 8.
Code examples can be viewed on github:
https://github.com/levmyshkin/drupalbook8
Let's start by adding a file containing a PHP class, this is how blocks are created in Drupal through a custom module. The process of creating the file is the same as the class for the page, as we did here:
We can use the parameters in the URL for routes. They work just like contextual filters in Views. We can for example pass in the URL the ID of various entities, text strings or sequential ID separated by comma or pluses. In this lesson, we will pass the ID of the node and display the title and body of this node in the content.
Code examples can be viewed on github:
https://github.com/levmyshkin/drupalbook8
Let's add route to our drupalbook.routing.yml module file:
As you learn the Drupal API, you will often need to refer to the main documentation at https://api.drupal.org. This is the automatically generated Drupal documentation. It contains all the information about each function, class, method, where they are defined, where a brief description is used. Also on this site there is API help, I advise you to familiarize yourself with each of the sections: