SlideShare a Scribd company logo
Drupal Modules
   Module Building 101
What is a module?
•   Core Modules
    o Node
    o Comment
    o File
    o Image
    o etc...
•   Contrib Modules
    o Views
    o Webform
    o Block Class
    o Eldorado Superfly
    o etc...
Why more?
Reasons
• Performance
• New Functionality
• Glue Modules
• Tweak Modules
Performance
• Good modules are abstract
• Abstraction can be slow
• Slow is bad
• Custom tailored code can be faster
• Tailoring for one site is easier than tailoring
  for all possible sites now and in the future.
New Functionality


• Because 18,000 just isn’t enough
Glue Modules

• API Hooks
• Tie functionality together
• Most sites could use one
Tweak Modules
• hook_menu_alter()
• hook_menu_link_alter()
• hook_menu_breadcrumb_alter()
• etc...
Tools of the trade
•   http://api.drupal.org
•   http://api.drupalize.me
•   http://drupal.org/project/module_builder
•   http://drupal.org/project/devel (dpm)
•   http://drupal.org/project/schema
•   http://php.net
•   Editor with a step-through debugger (Eclipse,
    Komodo, VIM)
Anatomy of a module
• Placement
 - sites/all/modules/custom/mymodule
• File names
• Required Files
• Hooks
Required Files
• mymodule.info
• mymodule.module

• mymodule.install

• ...others as needed
What’s in a name?
• module_implements($hook)
• module_invoke_all($hook)
hook = modulename
e.g.

views.module, hook_menu() means
   views_menu()
Hooks to know
• hook_menu()
• hook_form_alter()
• hook_block_*()
• hook_node_*()
• hook_entity_*()
• hook_user_*()
Working with forms
• drupal_get_form(‘my_form’)
• my_form() // returns an array
• my_form_validate($form, $form_state)
• my_form_submit($form, $form_state)
• hook_form_alter()
Tips for getting started
•   Read code

    -   examples.module

    -   core modules

•   Contribute

    -   core office hours

    -   issue queues

    -   IRC, #drupal, #drupal-contribute

More Related Content

PDF
Niyum framework
KEY
A nodejs application
PDF
Drupal Developer Skills (2012) - DrupalCamp LA 2012
PPTX
BDD in Drupal 8 Using Behat, mink and Selenium
PPTX
Building and Managing Projects with Maven
ZIP
Rails 3 (beta) Roundup
PDF
Drupal Step-by-Step: How We Built Our Training Site, Part 2
PPTX
Static website generator
Niyum framework
A nodejs application
Drupal Developer Skills (2012) - DrupalCamp LA 2012
BDD in Drupal 8 Using Behat, mink and Selenium
Building and Managing Projects with Maven
Rails 3 (beta) Roundup
Drupal Step-by-Step: How We Built Our Training Site, Part 2
Static website generator

What's hot (20)

PDF
新版阿尔法城背后的前端MVC实践
PDF
Efektivny vyvoj v drupale
PDF
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)
PDF
Drupal 8 - What’s cooking?
PDF
Alfresco Day Stockholm 2015 - Rapid UI Development
ODP
Xitrum @ Scala Conference in Japan 2013
KEY
Beautiful Maintainable ModularJavascript Codebase with RequireJS - HelsinkiJ...
PDF
How to start developing apps for Firefox OS
KEY
Efficient theming in Drupal
PDF
Bootstrap vs. Skeleton
PPT
Developing Rest services with SailsJs by Andrey Kolodnitskiy
PPTX
East Coast DevCon 2014: Programming in UE4 - A Quick Orientation for Coders
PPTX
SoCal Code Camp 2011 - ASP.NET 4.5
PPTX
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
PPTX
Nodejs Training in Hyderabad
PDF
MVC with Zend Framework
PPTX
Web Ninja
PPTX
Wheel.js
PPTX
Web components, so close!
PPTX
Maven
新版阿尔法城背后的前端MVC实践
Efektivny vyvoj v drupale
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)
Drupal 8 - What’s cooking?
Alfresco Day Stockholm 2015 - Rapid UI Development
Xitrum @ Scala Conference in Japan 2013
Beautiful Maintainable ModularJavascript Codebase with RequireJS - HelsinkiJ...
How to start developing apps for Firefox OS
Efficient theming in Drupal
Bootstrap vs. Skeleton
Developing Rest services with SailsJs by Andrey Kolodnitskiy
East Coast DevCon 2014: Programming in UE4 - A Quick Orientation for Coders
SoCal Code Camp 2011 - ASP.NET 4.5
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
Nodejs Training in Hyderabad
MVC with Zend Framework
Web Ninja
Wheel.js
Web components, so close!
Maven
Ad

Similar to Module development (20)

PDF
Your first d8 module
PDF
MIGRATION - PAIN OR GAIN?
PDF
Staying Sane with Drupal (A Develper's Survival Guide)
PDF
Blisstering drupal module development ppt v1.2
PDF
Drupal 8 Deep Dive: Plugin System
PPTX
Drupal module development
PDF
Intro to Drupal Module Developement
PPTX
Drupal Skils Lab 302Labs
PPT
5 Common Mistakes You are Making on your Website
KEY
Top modules
PDF
Drupal 8 deeper dive
PDF
Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011
PPT
Drupal: an Overview
PPTX
AngularJS
PPTX
Resources for Navigating Drupal Upgrades: Versions 6 Through 8 And What It Me...
PDF
Drupal 8 - Core and API Changes
KEY
DrupalCon 2011 Highlight
PDF
Drupal theming - a practical approach (European Drupal Days 2015)
PPTX
East Coast DevCon 2014: Engine Overview - A Programmer’s Glimpse at UE4
PPTX
Top 20 mistakes you will make on your 1st Drupal project
Your first d8 module
MIGRATION - PAIN OR GAIN?
Staying Sane with Drupal (A Develper's Survival Guide)
Blisstering drupal module development ppt v1.2
Drupal 8 Deep Dive: Plugin System
Drupal module development
Intro to Drupal Module Developement
Drupal Skils Lab 302Labs
5 Common Mistakes You are Making on your Website
Top modules
Drupal 8 deeper dive
Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011
Drupal: an Overview
AngularJS
Resources for Navigating Drupal Upgrades: Versions 6 Through 8 And What It Me...
Drupal 8 - Core and API Changes
DrupalCon 2011 Highlight
Drupal theming - a practical approach (European Drupal Days 2015)
East Coast DevCon 2014: Engine Overview - A Programmer’s Glimpse at UE4
Top 20 mistakes you will make on your 1st Drupal project
Ad

Recently uploaded (20)

PDF
KodekX | Application Modernization Development
PDF
Approach and Philosophy of On baking technology
PDF
Electronic commerce courselecture one. Pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPT
Teaching material agriculture food technology
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
cuic standard and advanced reporting.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Empathic Computing: Creating Shared Understanding
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Cloud computing and distributed systems.
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
KodekX | Application Modernization Development
Approach and Philosophy of On baking technology
Electronic commerce courselecture one. Pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Teaching material agriculture food technology
Spectral efficient network and resource selection model in 5G networks
Mobile App Security Testing_ A Comprehensive Guide.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
cuic standard and advanced reporting.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Diabetes mellitus diagnosis method based random forest with bat algorithm
The AUB Centre for AI in Media Proposal.docx
20250228 LYD VKU AI Blended-Learning.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Empathic Computing: Creating Shared Understanding
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Cloud computing and distributed systems.
Dropbox Q2 2025 Financial Results & Investor Presentation

Module development

  • 1. Drupal Modules Module Building 101
  • 2. What is a module? • Core Modules o Node o Comment o File o Image o etc... • Contrib Modules o Views o Webform o Block Class o Eldorado Superfly o etc...
  • 4. Reasons • Performance • New Functionality • Glue Modules • Tweak Modules
  • 5. Performance • Good modules are abstract • Abstraction can be slow • Slow is bad • Custom tailored code can be faster • Tailoring for one site is easier than tailoring for all possible sites now and in the future.
  • 6. New Functionality • Because 18,000 just isn’t enough
  • 7. Glue Modules • API Hooks • Tie functionality together • Most sites could use one
  • 8. Tweak Modules • hook_menu_alter() • hook_menu_link_alter() • hook_menu_breadcrumb_alter() • etc...
  • 9. Tools of the trade • http://api.drupal.org • http://api.drupalize.me • http://drupal.org/project/module_builder • http://drupal.org/project/devel (dpm) • http://drupal.org/project/schema • http://php.net • Editor with a step-through debugger (Eclipse, Komodo, VIM)
  • 10. Anatomy of a module • Placement - sites/all/modules/custom/mymodule • File names • Required Files • Hooks
  • 11. Required Files • mymodule.info • mymodule.module • mymodule.install • ...others as needed
  • 12. What’s in a name? • module_implements($hook) • module_invoke_all($hook) hook = modulename e.g. views.module, hook_menu() means views_menu()
  • 13. Hooks to know • hook_menu() • hook_form_alter() • hook_block_*() • hook_node_*() • hook_entity_*() • hook_user_*()
  • 14. Working with forms • drupal_get_form(‘my_form’) • my_form() // returns an array • my_form_validate($form, $form_state) • my_form_submit($form, $form_state) • hook_form_alter()
  • 15. Tips for getting started • Read code - examples.module - core modules • Contribute - core office hours - issue queues - IRC, #drupal, #drupal-contribute