SlideShare a Scribd company logo
Drupal Module Development
“Hands-on”
Amit Vyas
http://drupal.org/user/246119
Rachit Gupta
https://drupal.org/user/403301
Overview
• Drupal Architecture
• Types of Drupal Modules
• Module Architecture
• Hooks 
• Hands On Module
Drupal Architecture
Technology Stack L(/W)AMP
Code Base (Drupal 7)
Database
Operating
System
Web Server
Language
Database Abstraction Layer
Technology Stack
Database
4
Types of Drupal Modules
Core Modules
Contributed Modules
Custom Modules
Core Modules
• Block:
Restricted to web administrator access only.
• Filter:
Authorized users and web administrators can choose from either
Filtered or Full HTML Input formats.
• Node:
Responsible for content.
• System:
Responsible for cron and caching.
Primary Web Site Admin. only.
• User:
User Management, Roles, Permissions.
Web administrator access only.
6
Contributed Modules
There are very high chances that what you are
looking for has already been developed 
 http://drupal.org/project/Modules
 http://drupalmodules.com/module-finder
 Google -> site:drupal.org/project <search
keywords> -cvs
No Luck!! 
Time to get hands dirty !!

How?
Custom Modules
• To extend functionality of contributed modules.
• To build features that are specific to your site.
• To build features that are not available through core or
contributed modules.
10
Make sure to look inside
related modules
Related =>
Modules that do things which are only
slightly different or slightly similar to the
things that you wound want your
module to do.
Module Architecture
“The building blocks of a module”
The .info file The .install file
The .module
file
The .inc file
.info file
• Drupal uses .info files (aka, "dot info files") to store metadata
about themes and modules. Various Drupal components use the
information in this file for module management.
• The .info file should have the same name as the .module file
and reside in the same directory. For example, if our module is
named drupal_training.module then your .info file should be
named drupal_training.info.
13
example.info File
name = “Drupal Training”
description = “Module for Drupal Training Day”
core = 7.x
package = “Training”
name (Required) The displayed name of your module. It should follow
the Drupal capitalization standard: only the first letter of the first word is
capitalized ("Example module"). Spaces are allowed as the name is used
mainly for the display purposes.
description (Required) A short, preferably one line description that will tell the
administrator what this module does on the module administration page.
core (Required) The version of Drupal that your module is for. For Drupal 6 this would
be 6.x, Drupal 7 would be 7.x, etc.
14
.inc file
• When Drupal loads a page, it loads all the .modules files of all
the active/enabled modules.
• If you have .inc (aka dot inc) file then .module will be loaded
when page loads BUT the inc file will not be loaded
• .inc file will be loaded for the specific page/path
• .inc file helps to reduce code loaded on a specific page/path
• hook_menu allows you to specify a .inc file for a specific path
15
Introduction to Hooks
What are hooks?
Why should I care?
16
What are hooks?
• A hook is really nothing more than a function that matches the
pattern of a call to the module functions .
• You can say that hook is a simple callback function that is called
on specific events.
• Pattern modulename_hookname()
• For example, if you want to do some operation on user
login, say sending an email to administrator on user logins into
the site, then no need to change the code in user module.
• Implement hook_user on your own module say “alert” by
defining function in your module file called alert_user and write
code to send an email to administrator here.
17
Why should I care?
• Modules Extends it’s functionality through hook system.
• One module communicates through other module through
hooks.
• The Hooks API provides a common naming standard for
hooks, allowing developers to implement them in custom
modules without needing to engage in extensive programming.
• The Hooks API allows developers to create their own hooks that
other modules can access, that leverage the same techniques
used in core Drupal.
• Many hooks are state aware, and operate differently depending
on what Drupal is actually doing when the hook is triggered.
18
Permissions, Access Control
hook_permission
hook_menu
Define menu items and page
callbacks.
Modify an existing form
hook_form_alter
Node operations
“The king of all hooks”
hook_nodeapi
Major hooks
 http://api.drupal.org/api/function/hook_user
 Gotcha: Not implementing the case delete.
Especially dangerous when modules own
tables have user related data. Just do it in the
memory of node/8
 http://api.drupal.org/api/function/hook_cron
 http://api.drupal.org/api/function/hook_block
Tools we can use…
 DATABASE API
 http://api.drupal.org/api/function/drupal_write_records
 http://api.drupal.org/api/function/user_roles
 http://api.drupal.org/api/function/format_interval
 http://api.drupal.org/api/function/user_multiple_role_edit
 http://api.drupal.org/api/function/user_load
 http://api.drupal.org/api/function/drupal_mail
 http://api.drupal.org/api/function/watchdog
 ~ 2200 more
25
Amit Vyas
http://drupal.org/user/246119
Rachit Gupta
https://drupal.org/user/403301

More Related Content

What's hot (20)

PPTX
Leveraging Open Source Library Guides: Integrating Koha and SubjectsPlus
Myka Kennedy Stephens
 
PPT
Open Source Content Management Systems
Matthew Turland
 
PDF
Drupal as a Rapid Application Development Framework for Non Profits / NGOs
Zyxware Technologies
 
PDF
Drupal Performance Audit and Optimization
Zyxware Technologies
 
PDF
Brian Campo, DoD JCS, Content.gov Presentation
Alfresco Software
 
PPTX
Open source wordpress and drupal
Ben Mango
 
PPTX
10reasons to choose_drupal
jeannette_modic
 
PDF
10reasons to choose_drupal
Balance Interactive
 
PPTX
MongoDB and MongoMK Source Event
Yuval Ararat
 
PPTX
You Can Be an Open Source Library
Myka Kennedy Stephens
 
PDF
Moving from PHP to a nodejs full stack CMS
Make & Build
 
PDF
Keystone.js 101
Alexander Roche
 
PPTX
Content Management System - CMS
Jaime Delgado
 
PPTX
Static Site Generators - Developing Websites in Low-resource Condition
IWMW
 
PPTX
Melbourne User Group OAK and MongoDB
Yuval Ararat
 
PPTX
Customising civicrm
Chris Ward
 
ODP
Framework
Deepan Sivasankar
 
PPTX
Multisite wp in education wc philly2011
Paul Muller
 
PPTX
Drupal Skils Lab 302Labs
Ahmad Mohamad Zain
 
PPTX
Php
Anas Farhad
 
Leveraging Open Source Library Guides: Integrating Koha and SubjectsPlus
Myka Kennedy Stephens
 
Open Source Content Management Systems
Matthew Turland
 
Drupal as a Rapid Application Development Framework for Non Profits / NGOs
Zyxware Technologies
 
Drupal Performance Audit and Optimization
Zyxware Technologies
 
Brian Campo, DoD JCS, Content.gov Presentation
Alfresco Software
 
Open source wordpress and drupal
Ben Mango
 
10reasons to choose_drupal
jeannette_modic
 
10reasons to choose_drupal
Balance Interactive
 
MongoDB and MongoMK Source Event
Yuval Ararat
 
You Can Be an Open Source Library
Myka Kennedy Stephens
 
Moving from PHP to a nodejs full stack CMS
Make & Build
 
Keystone.js 101
Alexander Roche
 
Content Management System - CMS
Jaime Delgado
 
Static Site Generators - Developing Websites in Low-resource Condition
IWMW
 
Melbourne User Group OAK and MongoDB
Yuval Ararat
 
Customising civicrm
Chris Ward
 
Multisite wp in education wc philly2011
Paul Muller
 
Drupal Skils Lab 302Labs
Ahmad Mohamad Zain
 

Viewers also liked (16)

PPTX
Presentación Baby (miniempresa)
Enrique Cox
 
PDF
Coursera Human-Computer Interaction
Svetlana Tytskaya
 
PPTX
Presentation1.PPTX
jameschloejames
 
PDF
Filme3
Luanapqt
 
PPTX
Characteristics of living things
Gayatri Rathod
 
DOCX
Lista de aprendizajes esp.erados
dacillugo1
 
PDF
Marato pobresa omnia solsona bloc 2
Punt òmnia Solsona
 
DOC
Practica 8 m10 7b
natirc2012
 
PDF
DE - ES Property aposta em projectos de reabilitação urbana - Miguel Guede...
Miguel Guedes de Sousa
 
PDF
Actividad 12
Rafael Brito Hernandez
 
PDF
December 2016 Redondo Beach Real Estate Market Trends Update
HHC South Bay Real Estate Agents
 
PDF
Raci myo
Al-Hatal Ndsb
 
PPT
Estetica corporal
Medical Class
 
DOC
Actividad 12 responsabilidad de la administración
Crojas17
 
PDF
Viaje cultural a Colmenar de Oreja
Universidad Popular Carmen de Michelena
 
PPTX
Curso auditoria ohsas 18001 1
Overallhealth En Salud
 
Presentación Baby (miniempresa)
Enrique Cox
 
Coursera Human-Computer Interaction
Svetlana Tytskaya
 
Presentation1.PPTX
jameschloejames
 
Filme3
Luanapqt
 
Characteristics of living things
Gayatri Rathod
 
Lista de aprendizajes esp.erados
dacillugo1
 
Marato pobresa omnia solsona bloc 2
Punt òmnia Solsona
 
Practica 8 m10 7b
natirc2012
 
DE - ES Property aposta em projectos de reabilitação urbana - Miguel Guede...
Miguel Guedes de Sousa
 
Actividad 12
Rafael Brito Hernandez
 
December 2016 Redondo Beach Real Estate Market Trends Update
HHC South Bay Real Estate Agents
 
Raci myo
Al-Hatal Ndsb
 
Estetica corporal
Medical Class
 
Actividad 12 responsabilidad de la administración
Crojas17
 
Viaje cultural a Colmenar de Oreja
Universidad Popular Carmen de Michelena
 
Curso auditoria ohsas 18001 1
Overallhealth En Salud
 
Ad

Similar to Drupal module development (20)

ODP
Intro to drupal module internals asheville
cgmonroe
 
PDF
Intro to Drupal Module Developement
Matt Mendonca
 
PPTX
Introduction And Basics of Modules in Drupal 7
Dhinakaran Mani
 
PPTX
Creating Drupal A Module
arcaneadam
 
ODP
Custom module and theme development in Drupal7
marif4pk
 
PPT
Module development
ingraminnovation
 
PPT
Drupal Modules
Amit Kumar Singh
 
PDF
13th Sep, Drupal 7 advanced training by TCS
DrupalMumbai
 
PDF
Drupal 7-api-2010-11-10
Shamsher Alam
 
PDF
2007 Fsoss Drupal Under The Hood
James Walker
 
PPT
Creating Custom Drupal Modules
tanoshimi
 
PPT
Advanced Module development
drupalindia
 
PDF
Session v1
Joe Crespo
 
PDF
Domas monkus drupal module development
Domas Monkus
 
PPT
Drupal 6 in a nutshell
Satish C Ayappan
 
PDF
Your first d8 module
tedbow
 
PDF
Ts drupal6 module development v0.2
Confiz
 
PPTX
Developing a Drupal module
Sayed Ahmed
 
PPTX
Developing a drupal module
Sayed Ahmed
 
Intro to drupal module internals asheville
cgmonroe
 
Intro to Drupal Module Developement
Matt Mendonca
 
Introduction And Basics of Modules in Drupal 7
Dhinakaran Mani
 
Creating Drupal A Module
arcaneadam
 
Custom module and theme development in Drupal7
marif4pk
 
Module development
ingraminnovation
 
Drupal Modules
Amit Kumar Singh
 
13th Sep, Drupal 7 advanced training by TCS
DrupalMumbai
 
Drupal 7-api-2010-11-10
Shamsher Alam
 
2007 Fsoss Drupal Under The Hood
James Walker
 
Creating Custom Drupal Modules
tanoshimi
 
Advanced Module development
drupalindia
 
Session v1
Joe Crespo
 
Domas monkus drupal module development
Domas Monkus
 
Drupal 6 in a nutshell
Satish C Ayappan
 
Your first d8 module
tedbow
 
Ts drupal6 module development v0.2
Confiz
 
Developing a Drupal module
Sayed Ahmed
 
Developing a drupal module
Sayed Ahmed
 
Ad

More from Rachit Gupta (6)

PPT
Drupal training day by Rachit Gupta
Rachit Gupta
 
PPTX
Drupal development environment
Rachit Gupta
 
PPTX
Drupal terminology
Rachit Gupta
 
PPTX
Drupal as CMS
Rachit Gupta
 
PPTX
Introduction to drupal
Rachit Gupta
 
PPTX
Drupal website in 45 mins
Rachit Gupta
 
Drupal training day by Rachit Gupta
Rachit Gupta
 
Drupal development environment
Rachit Gupta
 
Drupal terminology
Rachit Gupta
 
Drupal as CMS
Rachit Gupta
 
Introduction to drupal
Rachit Gupta
 
Drupal website in 45 mins
Rachit Gupta
 

Recently uploaded (20)

PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
Complete Network Protection with Real-Time Security
L4RGINDIA
 
PPTX
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
Complete Network Protection with Real-Time Security
L4RGINDIA
 
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 

Drupal module development

  • 1. Drupal Module Development “Hands-on” Amit Vyas http://drupal.org/user/246119 Rachit Gupta https://drupal.org/user/403301
  • 2. Overview • Drupal Architecture • Types of Drupal Modules • Module Architecture • Hooks  • Hands On Module
  • 3. Drupal Architecture Technology Stack L(/W)AMP Code Base (Drupal 7) Database
  • 5. Types of Drupal Modules Core Modules Contributed Modules Custom Modules
  • 6. Core Modules • Block: Restricted to web administrator access only. • Filter: Authorized users and web administrators can choose from either Filtered or Full HTML Input formats. • Node: Responsible for content. • System: Responsible for cron and caching. Primary Web Site Admin. only. • User: User Management, Roles, Permissions. Web administrator access only. 6
  • 7. Contributed Modules There are very high chances that what you are looking for has already been developed   http://drupal.org/project/Modules  http://drupalmodules.com/module-finder  Google -> site:drupal.org/project <search keywords> -cvs
  • 9. Time to get hands dirty !!  How?
  • 10. Custom Modules • To extend functionality of contributed modules. • To build features that are specific to your site. • To build features that are not available through core or contributed modules. 10
  • 11. Make sure to look inside related modules Related => Modules that do things which are only slightly different or slightly similar to the things that you wound want your module to do.
  • 12. Module Architecture “The building blocks of a module” The .info file The .install file The .module file The .inc file
  • 13. .info file • Drupal uses .info files (aka, "dot info files") to store metadata about themes and modules. Various Drupal components use the information in this file for module management. • The .info file should have the same name as the .module file and reside in the same directory. For example, if our module is named drupal_training.module then your .info file should be named drupal_training.info. 13
  • 14. example.info File name = “Drupal Training” description = “Module for Drupal Training Day” core = 7.x package = “Training” name (Required) The displayed name of your module. It should follow the Drupal capitalization standard: only the first letter of the first word is capitalized ("Example module"). Spaces are allowed as the name is used mainly for the display purposes. description (Required) A short, preferably one line description that will tell the administrator what this module does on the module administration page. core (Required) The version of Drupal that your module is for. For Drupal 6 this would be 6.x, Drupal 7 would be 7.x, etc. 14
  • 15. .inc file • When Drupal loads a page, it loads all the .modules files of all the active/enabled modules. • If you have .inc (aka dot inc) file then .module will be loaded when page loads BUT the inc file will not be loaded • .inc file will be loaded for the specific page/path • .inc file helps to reduce code loaded on a specific page/path • hook_menu allows you to specify a .inc file for a specific path 15
  • 16. Introduction to Hooks What are hooks? Why should I care? 16
  • 17. What are hooks? • A hook is really nothing more than a function that matches the pattern of a call to the module functions . • You can say that hook is a simple callback function that is called on specific events. • Pattern modulename_hookname() • For example, if you want to do some operation on user login, say sending an email to administrator on user logins into the site, then no need to change the code in user module. • Implement hook_user on your own module say “alert” by defining function in your module file called alert_user and write code to send an email to administrator here. 17
  • 18. Why should I care? • Modules Extends it’s functionality through hook system. • One module communicates through other module through hooks. • The Hooks API provides a common naming standard for hooks, allowing developers to implement them in custom modules without needing to engage in extensive programming. • The Hooks API allows developers to create their own hooks that other modules can access, that leverage the same techniques used in core Drupal. • Many hooks are state aware, and operate differently depending on what Drupal is actually doing when the hook is triggered. 18
  • 20. hook_menu Define menu items and page callbacks.
  • 21. Modify an existing form hook_form_alter
  • 22. Node operations “The king of all hooks” hook_nodeapi
  • 23. Major hooks  http://api.drupal.org/api/function/hook_user  Gotcha: Not implementing the case delete. Especially dangerous when modules own tables have user related data. Just do it in the memory of node/8  http://api.drupal.org/api/function/hook_cron  http://api.drupal.org/api/function/hook_block
  • 24. Tools we can use…  DATABASE API  http://api.drupal.org/api/function/drupal_write_records  http://api.drupal.org/api/function/user_roles  http://api.drupal.org/api/function/format_interval  http://api.drupal.org/api/function/user_multiple_role_edit  http://api.drupal.org/api/function/user_load  http://api.drupal.org/api/function/drupal_mail  http://api.drupal.org/api/function/watchdog  ~ 2200 more