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.
❗Extra Paragraph Types (EPT) - New Paragraphs experience
Extra Paragraph Types (EPT) - analogical paragraph based set of modules.
Scroll
- Home
- Drupal Documentation
- Creating modules for Drupal
- Creating block in Drupal module programmatically
Using configuration in block
13/04/2025, by Ivan
Menu
- Understanding Drupal
- Drupal System Requirements
- Installing Drupal 8
- Drupal 8 Update
- Drupal Site Administration
- Drupal 8 Modules
- Drupal Modules Comparison
- Drupal Themes
- Drupal field types
- Configuration Management
- Multisite Drupal
- Accessibility Features
- Troubleshooting in Drupal
-
Creating modules for Drupal
- Getting started - Drupal technical documentation
- Create Drupal module outline
- Naming and placing your Drupal module
- Mention Drupal about your module using .info.yml file
- Add composer.json file
- Output "Hello World" on page using Drupal module
- Adding main controller
- Add routing file
- Add a menu link
- Go next
- Add configuration for default values
- Enable default configuration in your Drupal 8 module
- Practical Guide to Creating Basic Modules in Drupal 8
- Drupal module structure
- Drupal configuration form
- Defining and Using Your Own Configuration in Drupal
- Create page in Drupal programmatically
- Creating block in Drupal module programmatically
- Creating Field Types, Widgets, and Formatters in Drupal
- Event Subscriber and Event Dispatcher. Working with events in Drupal
- Creating image style for Views in Drupal
- Adding template in Drupal module for theming
- Add CSS and JavaScript in Drupal module
- Testing Drupal module
- Publish your module on drupal.org
- Understanding hooks
- Drupal 8 API
- Theming in Drupal
- Upgrade to Drupal 11
To use block instance configuration, we can modify the build()
method of the HelloBlock
class:
/** * {@inheritdoc} */ public function build() { $config = $this->getConfiguration(); if (!empty($config['hello_block_name'])) { $name = $config['hello_block_name']; } else { $name = $this->t('to no one'); } return [ '#markup' => $this->t('Hello @name!', [ '@name' => $name, ]), ]; }
Source URL:
Source authors:
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.