Modules Development
1
‫تطوير‬‫الوحدات‬
1
Session Plan
❖ What are Drupal Modules?
❖ How we could find a requested Module?
❖ When we have to build a Custom Module?
❖ Examples
What are Drupal Modules?
Drupal Modules
drupal.org :: Download & Extend
Core (6.38 EOF:2/24/2016, 7.54, 8.3, 9.x)
Distributions (Profiles)
Themes (Payed Templates)
Modules (Contributed)
I. Drupal Module is a collection of files…
II. Reusable ( ) Functionality(ies)
A. Core (8.3.0: 66 Modules - Views / CKe)
B. Contributed (37,165)
C. Custom (.info.yml)
A & B: We are not allowed to be updated!
Drupal Modules
Drupal 8 Core Modules
Drupal Modules - Load
Drupal website URL:
Exp. http://demo.drupalcamp.kku.edu.sa/user
1. All requests goes through index.php (htaccess rules, ?q=)
2.Load enabled modules (DB Check)
3.Checks permissions (HTTP Request: 200, 403, 404)
4.Queries database for content
5.Renders theme page
Drupal 8 Core Modules
User Core Module
✓ Twig templates
✓ OOP PHP Language
✓ MVC Patterns
Symfony 2
New routing and context system.
Understanding Symfony2 => Better Drupal developer
How components work, which will help Drupal development ?
i. Symfony website
ii. Learn Symfony book
Drupal 8 improves on object-oriented programming & adapt to modern PHP
concepts.
Drupal core internals have never been better documented or learning them
more accessible thanks to the Symfony2 project’s resources; Doctrine
annotations.
Find a requested Module?
Find a Module?
Requested = Contributed
https://www.drupal.org/project/project_module
Install Drupal Module
As example, lets look for a Social Media Module…
Install Drupal Module
Download and Install the selected module
Become a Contributor
We are part of the community & we are invited to
contribute…
The ways to get involved:
★ User support
★ Documentation
★ Translations
★ Testing
★ Design and Usability
★ Development
★ Themes
Developer Contributor
Improving existing projects and core with patches
1. What is a patch
2. Creating patches (an overview)
3. Advanced patch contributor guide (with detailed Git instructions)
4. Applying patches (an overview)
5. Applying patches with Git (advanced guide)
Contributing new projects
1. Full projects, the standard downloadable modules and themes like Views
and Zen.
2. Sandbox projects, which are for experimental code, or code from new
contributors who've not been through a vetting process yet.
Building a Custom Module
Richard Branson
“ ‫الناس‬‫الذين‬‫ال‬‫يخطئون‬‫أبدا‬‫هم‬‫الذين‬‫ال‬‫يتعلمون‬ً‫إطالقا‬ ”
“You don't learn to walk by following rules. You
learn by doing, and by falling over.”
Building a custom module
We build a custom Module to
Create a new functionality
Alter a default behavior
We build a custom Module from
Scratch (.info.yml)
Clone of a core/contributed module
Drush (cli)
Let’s Build a First Module
Example 1: HelloWord
The routing…
Routing wildcard…
GitHub
Download link: https://github.com/yosriy82/KKU_DrupalCamp_demo1
Let’s Build a Second Module
Example 2: Alter Drupal Function
The module file
GitHub
Download link: https://github.com/yosriy82/KKU_DrupalCamp_demo2
‫شكرا‬‫لكم‬
‫فعالية‬‫دروبال‬‫برعاية‬

Drupal 8 Modules