logo

Extra Block Types (EBT) - New Layout Builder experienceâť—

Extra Block Types (EBT) - styled, customizable block types: Slideshows, Tabs, Cards, Accordions and many others. Built-in settings for background, DOM Box, javascript plugins. Experience the future of layout building today.

Demo EBT modules Download EBT modules

âť—Extra Paragraph Types (EPT) - New Paragraphs experience

Extra Paragraph Types (EPT) - analogical paragraph based set of modules.

Demo EPT modules Download EPT modules

Scroll

Articles

13/04/2025, by Ivan

This page provides an example of how to create a configuration entity type with administrative management pages in Drupal 8. For an introduction to the concepts of simple configuration and configuration entities, see https://drupal.org/node/2120523.

After enabling the example module that contains the code below, the configuration form should be available at “admin/config/system/example”, as shown in the screenshot:

2016-12-18-002716

Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.

13/04/2025, by Ivan

Using $config in the Context of a Form

This page describes the API for retrieving and setting configuration data for simple configuration. (This does not apply to information stored in configuration objects.)

Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.

13/04/2025, by Ivan

Using $config in the Context of a Form

You can use configuration forms to see how $config can retrieve user-entered data and update information in the {module}.settings.yml file. Here's the code to declare a $config object within a form, typically found in a PHP settings form file.

Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.

13/04/2025, by Ivan

The Drupal 8 Database API provides a standardized, vendor-independent abstraction layer for accessing database servers. You should almost never make direct database calls unless you are developing core APIs.

The API is designed to preserve the syntax and power of SQL as much as possible, while also:

Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.

13/04/2025, by Ivan

The Drupal database layer is built on top of the PHP PDO library. PDO provides a unified, object-oriented API for accessing various databases, but it does not offer abstraction for the different SQL dialects used by different database systems.

Source URL:

Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.

13/04/2025, by Ivan

The primary way to define a database connection in Drupal is through the $databases array in settings.php. As the name suggests, $databases allows you to define multiple database connections. It also supports defining multiple targets. A connection to the database is not opened (i.e., the connection object is not created) until the first piece of code attempts to run a query against that database.

Connection Key

Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.

13/04/2025, by Ivan

Interaction with the database should be done through the database connection object. There are several scenarios that require attention:

1. In procedural code, i.e., *.module, *.inc, or script files:
The best way to instantiate the database connection object is via the Service Container.

Example:

Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.

13/04/2025, by Ivan

The most common SELECT queries in Drupal are static queries using the query() method of the database connection object.
Static queries are passed to the database almost verbatim.

Example:

Source URL:

Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.

13/04/2025, by Ivan

To create a Drupal 8 theme, you must first create a THEMENAME.info.yml file that provides metadata about your theme in Drupal. This is similar to how modules and installation profiles are defined, so it's important to set the "type" key in the file.info.yml as "theme" to differentiate it.

This page contains an example of a THEMENAME.info.yml file and an overview of the information it may contain.

Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.