-
EBT Blocks 🧱
-
EPT Paragraphs 🆕
-
Resources & Support
- Drupal Book
- Blog
- Case Studies
- Drupal Documentation
- JSON Drop API Documentation
- Forum
- What's New
- Download Drupal
- Contact
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.
GLightbox is a pure javascript lightbox (Colorbox alternative without jQuery)❗
It can display images, iframes, inline content and videos with optional autoplay for YouTube, Vimeo and even self-hosted videos.
Adding main controller
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
The content() function in the HelloController class will return markup text when the routing system calls the page.
In your module folder, you should have the standard PSR-4 folder structure /src/Controller, and inside this folder, you should have the controller file HelloController.php.
Thus, your controller file will be located at
/src/Controller/HelloController.php
You have the following code in the HelloController.php file:
<?php
namespace Drupal\hello_world\Controller;
use Drupal\Core\Controller\ControllerBase;
/**
* Defines HelloController class.
*/
class HelloController extends ControllerBase {
/**
* Display the markup.
*
* @return array
* Return markup array.
*/
public function content() {
return [
'#type' => 'markup',
'#markup' => $this->t('Hello, World!'),
];
}
}
This code alone will not do anything. It must be triggered by adding a routing file to our module. However, adding the controller to our code first is part of the general D8 philosophy: “Build the tool, then connect it.”