SlideShare a Scribd company logo
1 of 25
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

Leveraging Open Source Library Guides: Integrating Koha and SubjectsPlus
Leveraging Open Source Library Guides: Integrating Koha and SubjectsPlusLeveraging Open Source Library Guides: Integrating Koha and SubjectsPlus
Leveraging Open Source Library Guides: Integrating Koha and SubjectsPlusMyka Kennedy Stephens
 
Open Source Content Management Systems
Open Source Content Management SystemsOpen Source Content Management Systems
Open Source Content Management SystemsMatthew Turland
 
Drupal as a Rapid Application Development Framework for Non Profits / NGOs
Drupal as a Rapid Application Development Framework for Non Profits / NGOsDrupal as a Rapid Application Development Framework for Non Profits / NGOs
Drupal as a Rapid Application Development Framework for Non Profits / NGOsZyxware Technologies
 
Drupal Performance Audit and Optimization
Drupal Performance Audit and OptimizationDrupal Performance Audit and Optimization
Drupal Performance Audit and OptimizationZyxware Technologies
 
Brian Campo, DoD JCS, Content.gov Presentation
Brian Campo, DoD JCS, Content.gov PresentationBrian Campo, DoD JCS, Content.gov Presentation
Brian Campo, DoD JCS, Content.gov PresentationAlfresco Software
 
Open source wordpress and drupal
Open source wordpress and drupalOpen source wordpress and drupal
Open source wordpress and drupalBen Mango
 
10reasons to choose_drupal
10reasons to choose_drupal10reasons to choose_drupal
10reasons to choose_drupaljeannette_modic
 
MongoDB and MongoMK Source Event
MongoDB and MongoMK Source EventMongoDB and MongoMK Source Event
MongoDB and MongoMK Source EventYuval Ararat
 
Moving from PHP to a nodejs full stack CMS
Moving from PHP to a nodejs full stack CMSMoving from PHP to a nodejs full stack CMS
Moving from PHP to a nodejs full stack CMSMake & Build
 
Content Management System - CMS
 Content Management System - CMS Content Management System - CMS
Content Management System - CMSJaime Delgado
 
Static Site Generators - Developing Websites in Low-resource Condition
Static Site Generators - Developing Websites in Low-resource ConditionStatic Site Generators - Developing Websites in Low-resource Condition
Static Site Generators - Developing Websites in Low-resource ConditionIWMW
 
Melbourne User Group OAK and MongoDB
Melbourne User Group OAK and MongoDBMelbourne User Group OAK and MongoDB
Melbourne User Group OAK and MongoDBYuval Ararat
 
Customising civicrm
Customising civicrmCustomising civicrm
Customising civicrmChris Ward
 
Multisite wp in education wc philly2011
Multisite wp in education wc philly2011Multisite wp in education wc philly2011
Multisite wp in education wc philly2011Paul Muller
 

What's hot (20)

Leveraging Open Source Library Guides: Integrating Koha and SubjectsPlus
Leveraging Open Source Library Guides: Integrating Koha and SubjectsPlusLeveraging Open Source Library Guides: Integrating Koha and SubjectsPlus
Leveraging Open Source Library Guides: Integrating Koha and SubjectsPlus
 
Open Source Content Management Systems
Open Source Content Management SystemsOpen Source Content Management Systems
Open Source Content Management Systems
 
Drupal as a Rapid Application Development Framework for Non Profits / NGOs
Drupal as a Rapid Application Development Framework for Non Profits / NGOsDrupal as a Rapid Application Development Framework for Non Profits / NGOs
Drupal as a Rapid Application Development Framework for Non Profits / NGOs
 
Drupal Performance Audit and Optimization
Drupal Performance Audit and OptimizationDrupal Performance Audit and Optimization
Drupal Performance Audit and Optimization
 
Brian Campo, DoD JCS, Content.gov Presentation
Brian Campo, DoD JCS, Content.gov PresentationBrian Campo, DoD JCS, Content.gov Presentation
Brian Campo, DoD JCS, Content.gov Presentation
 
Open source wordpress and drupal
Open source wordpress and drupalOpen source wordpress and drupal
Open source wordpress and drupal
 
10reasons to choose_drupal
10reasons to choose_drupal10reasons to choose_drupal
10reasons to choose_drupal
 
10reasons to choose_drupal
10reasons to choose_drupal10reasons to choose_drupal
10reasons to choose_drupal
 
MongoDB and MongoMK Source Event
MongoDB and MongoMK Source EventMongoDB and MongoMK Source Event
MongoDB and MongoMK Source Event
 
You Can Be an Open Source Library
You Can Be an Open Source LibraryYou Can Be an Open Source Library
You Can Be an Open Source Library
 
Moving from PHP to a nodejs full stack CMS
Moving from PHP to a nodejs full stack CMSMoving from PHP to a nodejs full stack CMS
Moving from PHP to a nodejs full stack CMS
 
Keystone.js 101
Keystone.js 101Keystone.js 101
Keystone.js 101
 
Content Management System - CMS
 Content Management System - CMS Content Management System - CMS
Content Management System - CMS
 
Static Site Generators - Developing Websites in Low-resource Condition
Static Site Generators - Developing Websites in Low-resource ConditionStatic Site Generators - Developing Websites in Low-resource Condition
Static Site Generators - Developing Websites in Low-resource Condition
 
Melbourne User Group OAK and MongoDB
Melbourne User Group OAK and MongoDBMelbourne User Group OAK and MongoDB
Melbourne User Group OAK and MongoDB
 
Customising civicrm
Customising civicrmCustomising civicrm
Customising civicrm
 
Framework
FrameworkFramework
Framework
 
Multisite wp in education wc philly2011
Multisite wp in education wc philly2011Multisite wp in education wc philly2011
Multisite wp in education wc philly2011
 
Drupal Skils Lab 302Labs
Drupal Skils Lab 302Labs Drupal Skils Lab 302Labs
Drupal Skils Lab 302Labs
 
Php
PhpPhp
Php
 

Viewers also liked

Presentación Baby (miniempresa)
Presentación Baby (miniempresa)Presentación Baby (miniempresa)
Presentación Baby (miniempresa)Enrique Cox
 
Coursera Human-Computer Interaction
Coursera Human-Computer InteractionCoursera Human-Computer Interaction
Coursera Human-Computer InteractionSvetlana Tytskaya
 
Characteristics of living things
Characteristics of living thingsCharacteristics of living things
Characteristics of living thingsGayatri Rathod
 
Lista de aprendizajes esp.erados
Lista de aprendizajes esp.eradosLista de aprendizajes esp.erados
Lista de aprendizajes esp.eradosdacillugo1
 
Marato pobresa omnia solsona bloc 2
Marato pobresa omnia solsona bloc 2Marato pobresa omnia solsona bloc 2
Marato pobresa omnia solsona bloc 2Punt òmnia Solsona
 
Practica 8 m10 7b
Practica 8 m10 7bPractica 8 m10 7b
Practica 8 m10 7bnatirc2012
 
DE - ES Property aposta em projectos de reabilitação urbana - Miguel Guede...
DE -  ES Property aposta em projectos de reabilitação urbana - Miguel Guede...DE -  ES Property aposta em projectos de reabilitação urbana - Miguel Guede...
DE - ES Property aposta em projectos de reabilitação urbana - Miguel Guede...Miguel Guedes de Sousa
 
December 2016 Redondo Beach Real Estate Market Trends Update
December 2016 Redondo Beach Real Estate Market Trends UpdateDecember 2016 Redondo Beach Real Estate Market Trends Update
December 2016 Redondo Beach Real Estate Market Trends UpdateHHC South Bay Real Estate Agents
 
Actividad 12 responsabilidad de la administración
Actividad 12   responsabilidad de la administraciónActividad 12   responsabilidad de la administración
Actividad 12 responsabilidad de la administraciónCrojas17
 

Viewers also liked (16)

Presentación Baby (miniempresa)
Presentación Baby (miniempresa)Presentación Baby (miniempresa)
Presentación Baby (miniempresa)
 
Coursera Human-Computer Interaction
Coursera Human-Computer InteractionCoursera Human-Computer Interaction
Coursera Human-Computer Interaction
 
Presentation1.PPTX
Presentation1.PPTXPresentation1.PPTX
Presentation1.PPTX
 
Filme3
Filme3Filme3
Filme3
 
Characteristics of living things
Characteristics of living thingsCharacteristics of living things
Characteristics of living things
 
Lista de aprendizajes esp.erados
Lista de aprendizajes esp.eradosLista de aprendizajes esp.erados
Lista de aprendizajes esp.erados
 
Marato pobresa omnia solsona bloc 2
Marato pobresa omnia solsona bloc 2Marato pobresa omnia solsona bloc 2
Marato pobresa omnia solsona bloc 2
 
Practica 8 m10 7b
Practica 8 m10 7bPractica 8 m10 7b
Practica 8 m10 7b
 
DE - ES Property aposta em projectos de reabilitação urbana - Miguel Guede...
DE -  ES Property aposta em projectos de reabilitação urbana - Miguel Guede...DE -  ES Property aposta em projectos de reabilitação urbana - Miguel Guede...
DE - ES Property aposta em projectos de reabilitação urbana - Miguel Guede...
 
Actividad 12
Actividad 12 Actividad 12
Actividad 12
 
December 2016 Redondo Beach Real Estate Market Trends Update
December 2016 Redondo Beach Real Estate Market Trends UpdateDecember 2016 Redondo Beach Real Estate Market Trends Update
December 2016 Redondo Beach Real Estate Market Trends Update
 
Raci myo
Raci myoRaci myo
Raci myo
 
Estetica corporal
Estetica corporalEstetica corporal
Estetica corporal
 
Actividad 12 responsabilidad de la administración
Actividad 12   responsabilidad de la administraciónActividad 12   responsabilidad de la administración
Actividad 12 responsabilidad de la administración
 
Viaje cultural a Colmenar de Oreja
Viaje cultural a Colmenar de OrejaViaje cultural a Colmenar de Oreja
Viaje cultural a Colmenar de Oreja
 
Curso auditoria ohsas 18001 1
Curso auditoria ohsas 18001 1Curso auditoria ohsas 18001 1
Curso auditoria ohsas 18001 1
 

Similar to Drupal module development

Blisstering drupal module development ppt v1.2
Blisstering drupal module development ppt v1.2Blisstering drupal module development ppt v1.2
Blisstering drupal module development ppt v1.2Anil Sagar
 
Top 20 mistakes you will make on your 1st Drupal project
Top 20 mistakes you will make on your 1st Drupal projectTop 20 mistakes you will make on your 1st Drupal project
Top 20 mistakes you will make on your 1st Drupal projectIztok Smolic
 
Rapid site production with Drupal
Rapid site production with DrupalRapid site production with Drupal
Rapid site production with DrupalRob Sawyer
 
Oleksandr Medvediev - Content delivery tools in Drupal 8.
Oleksandr Medvediev - Content delivery tools in Drupal 8.Oleksandr Medvediev - Content delivery tools in Drupal 8.
Oleksandr Medvediev - Content delivery tools in Drupal 8.DrupalCamp Kyiv
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesShabir Ahmad
 
Drupal8 corporate training in Hyderabad
Drupal8 corporate training in HyderabadDrupal8 corporate training in Hyderabad
Drupal8 corporate training in Hyderabadphp2ranjan
 
Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To DrupalLauren Roth
 
Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Angela Byron
 
Everything You Need to Know About the Top Changes in Drupal 8
Everything You Need to Know About the Top Changes in Drupal 8Everything You Need to Know About the Top Changes in Drupal 8
Everything You Need to Know About the Top Changes in Drupal 8Acquia
 
Your first d8 module
Your first d8 moduleYour first d8 module
Your first d8 moduletedbow
 
Intro to Drupal Module Developement
Intro to Drupal Module DevelopementIntro to Drupal Module Developement
Intro to Drupal Module DevelopementMatt Mendonca
 
13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS 13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS DrupalMumbai
 
Drupal 7x Installation - Introduction to Drupal Concepts
Drupal 7x Installation - Introduction to Drupal ConceptsDrupal 7x Installation - Introduction to Drupal Concepts
Drupal 7x Installation - Introduction to Drupal ConceptsMicky Metts
 
Custom module and theme development in Drupal7
Custom module and theme development in Drupal7Custom module and theme development in Drupal7
Custom module and theme development in Drupal7marif4pk
 
Drupal 7 Features - Introduction - Basics
Drupal 7 Features - Introduction - BasicsDrupal 7 Features - Introduction - Basics
Drupal 7 Features - Introduction - BasicsDhinakaran Mani
 
Architecture of Drupal - Drupal Camp
Architecture of Drupal - Drupal CampArchitecture of Drupal - Drupal Camp
Architecture of Drupal - Drupal CampDipen Chaudhary
 

Similar to Drupal module development (20)

Blisstering drupal module development ppt v1.2
Blisstering drupal module development ppt v1.2Blisstering drupal module development ppt v1.2
Blisstering drupal module development ppt v1.2
 
Top 20 mistakes you will make on your 1st Drupal project
Top 20 mistakes you will make on your 1st Drupal projectTop 20 mistakes you will make on your 1st Drupal project
Top 20 mistakes you will make on your 1st Drupal project
 
Rapid site production with Drupal
Rapid site production with DrupalRapid site production with Drupal
Rapid site production with Drupal
 
Oleksandr Medvediev - Content delivery tools in Drupal 8.
Oleksandr Medvediev - Content delivery tools in Drupal 8.Oleksandr Medvediev - Content delivery tools in Drupal 8.
Oleksandr Medvediev - Content delivery tools in Drupal 8.
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API Changes
 
Drupal8 corporate training in Hyderabad
Drupal8 corporate training in HyderabadDrupal8 corporate training in Hyderabad
Drupal8 corporate training in Hyderabad
 
Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To Drupal
 
Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8
 
Everything You Need to Know About the Top Changes in Drupal 8
Everything You Need to Know About the Top Changes in Drupal 8Everything You Need to Know About the Top Changes in Drupal 8
Everything You Need to Know About the Top Changes in Drupal 8
 
Dn D Custom 1
Dn D Custom 1Dn D Custom 1
Dn D Custom 1
 
Dn D Custom 1
Dn D Custom 1Dn D Custom 1
Dn D Custom 1
 
Your first d8 module
Your first d8 moduleYour first d8 module
Your first d8 module
 
Intro to Drupal Module Developement
Intro to Drupal Module DevelopementIntro to Drupal Module Developement
Intro to Drupal Module Developement
 
13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS 13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS
 
Drupal6 and Drupal 7 difference
Drupal6 and Drupal 7 differenceDrupal6 and Drupal 7 difference
Drupal6 and Drupal 7 difference
 
Drupal 7x Installation - Introduction to Drupal Concepts
Drupal 7x Installation - Introduction to Drupal ConceptsDrupal 7x Installation - Introduction to Drupal Concepts
Drupal 7x Installation - Introduction to Drupal Concepts
 
Drupal
DrupalDrupal
Drupal
 
Custom module and theme development in Drupal7
Custom module and theme development in Drupal7Custom module and theme development in Drupal7
Custom module and theme development in Drupal7
 
Drupal 7 Features - Introduction - Basics
Drupal 7 Features - Introduction - BasicsDrupal 7 Features - Introduction - Basics
Drupal 7 Features - Introduction - Basics
 
Architecture of Drupal - Drupal Camp
Architecture of Drupal - Drupal CampArchitecture of Drupal - Drupal Camp
Architecture of Drupal - Drupal Camp
 

More from Rachit Gupta

Drupal training day by Rachit Gupta
Drupal training day by Rachit GuptaDrupal training day by Rachit Gupta
Drupal training day by Rachit GuptaRachit Gupta
 
Drupal development environment
Drupal development environmentDrupal development environment
Drupal development environmentRachit Gupta
 
Drupal terminology
Drupal terminologyDrupal terminology
Drupal terminologyRachit Gupta
 
Introduction to drupal
 Introduction to drupal Introduction to drupal
Introduction to drupalRachit Gupta
 
Drupal website in 45 mins
Drupal website in 45 minsDrupal website in 45 mins
Drupal website in 45 minsRachit Gupta
 

More from Rachit Gupta (6)

Drupal training day by Rachit Gupta
Drupal training day by Rachit GuptaDrupal training day by Rachit Gupta
Drupal training day by Rachit Gupta
 
Drupal development environment
Drupal development environmentDrupal development environment
Drupal development environment
 
Drupal terminology
Drupal terminologyDrupal terminology
Drupal terminology
 
Drupal as CMS
Drupal as CMSDrupal as CMS
Drupal as CMS
 
Introduction to drupal
 Introduction to drupal Introduction to drupal
Introduction to drupal
 
Drupal website in 45 mins
Drupal website in 45 minsDrupal website in 45 mins
Drupal website in 45 mins
 

Recently uploaded

Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfAarwolf Industries LLC
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Nikki Chapple
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...itnewsafrica
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 

Recently uploaded (20)

Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdf
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 

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