SlideShare a Scribd company logo
CMS +  framework + Community
Getting Involved!
do (drupal_module_development)  or  die(a_noob); /* Btw.. That is the official title of this talk. */
Hooks
Drupal API http://api.drupal.org/
Seek the purpose You got to answer some questions. | a good starting point | What do I want to do?
Answers to be found The end user should be able to do this ___________ .  __________ be done to the end user. All corollaries of #1 and #2 After all..
end user
Lets say we want… This is how  user profile page  should look like to anybody visiting it. Block   displaying currently logged in users “role length” details **  we also want the user to receive ‘n’ number of  automated mail notifications  as he is approaching a particular role expiry. User account page Member Since: 3weeks 2days Has role ‘lucky’: expires in 13 more days Has role ‘geek’: Never expires BLAH.. BLAH… <Username> Role ‘rookie’: expires in 14 days Role ‘content contributor’: expires in 100 days
Some more answers to be found Does the admin need to be bothered? What settings/configurations ought to be exposed to the admin? What is the right place (drupal path) to do this? Okay.. So how should the form(s) look like?
Lets say we want…
Lets say we want…
Try all PnC Highly recommended  to evaluate if the requirements can be fulfilled by PnC of drupal core + “killer modules” Drupal core Core – Optional modules Cck, Views, Panels et al
Contributions!! Where? How? 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?
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.
Indispensable development help
Indispensable development help Coder Schema Form Builder Devel
Determine the schema Requirement collection starts form  the user . Development should start from  the database . Map the  schema  to all/any mock ups you have prepared.
Schema mockup role_length rid int rlength int exprid int asg_mail text  exp_mail text role_length_user_ roles rid tinyint uid int asg_time timestamp expmail_sent text
Map schema to everything else in the UI mockups just created
**  we also want the user to receive ‘n’ number of mail notifications as he is approaching a particular role expiry. Check if we have all the data that we need.  * Avoid redundancy. There is a lot of data in tables not created by the module being developed. role_length rid int rlength int exprid int asg_mail text  exp_mail text role_length_user_roles rid tinyint uid int asg_time timestamp expmail_sent text  User account page Member Since: 3weeks 2days Has role ‘lucky’: expires in 13 more days Has role ‘geek’: Never expires BLAH.. BLAH… <Username> Role ‘rookie’: expires in 14 days Role ‘content contributor’: expires in 100 days
Creating .info and .install files Use dependencies only when core functionality of your module depends upon other modules ELSE use module_exists() Schema API ? http://api.drupal.org/api/function/hook_install http://api.drupal.org/api/function/hook_uninstall http://api.drupal.org/api/function/hook_install_schema http://api.drupal.org/api/function/hook_schema
Creating .module file http://api.drupal.org/api/function/hook_help http://api.drupal.org/api/function/hook_menu Form API ? http://api.drupal.org/api/file/form_api_reference.html/6 http://api.drupal.org/api/function/hook_form_alter AHAH !!
Best practices to structure  $form Why are they called “best practices” ?
How to: dynamic forms and  forms that “grow” what is the difference!!??
jQuery To jazz up your forms with tool tips, pop-ins, char count et al. AHAH FAPI + menu callback To ajaxify forms without changing the types of or number of elements in the form. (eg: username availability) AHAH FAPI + menu callback + form rebuilding To asynchronously grow the form. Adding/Removing elements or changing types of elements.
Changing forms asynchronously Initially requests for the form Build the form > Send out the rendered form > Save form state in the cache Acts upon the AHAH element “ AHAH callback” fetches form from the cache > build it using $_POST values > Add/Removes/Modifies elements > Set the cache > Output changes as JSON AHAH grabs the JSON response and does the magic.
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
Ain’t Drupal  beautiful ?! To keep it that way don’t spit out your output, theme it.
Ta-Da!! ® Lets go to  node/59
http://drupal.org/node/100748 Add code to CVS Create the project on drupal.org Create a release Add a handbook page
May  the force  be with you
? Sumeet Pareek aka WikidKaka positivecharge (at) gmail (dot) com http://sumeetpareek.com http://drupal.org/user/301925

More Related Content

What's hot (8)

PDF
Javascript spaghetti stirtrek_5_17
Jared Faris
 
PDF
WordCamp ABQ 2013: Making the leap from Designer to Designer/Developer
my easel
 
PDF
Wordcamp abq cf-cpt
my easel
 
PDF
Git Makes Me Angry Inside
Emma Jane Hogbin Westby
 
PDF
22 j query1
Fajar Baskoro
 
DOC
javscript
rcc1964
 
PDF
Future of Web Development
Zeno Rocha
 
PPTX
MVC Frameworks for building PHP Web Applications
Vforce Infotech
 
Javascript spaghetti stirtrek_5_17
Jared Faris
 
WordCamp ABQ 2013: Making the leap from Designer to Designer/Developer
my easel
 
Wordcamp abq cf-cpt
my easel
 
Git Makes Me Angry Inside
Emma Jane Hogbin Westby
 
22 j query1
Fajar Baskoro
 
javscript
rcc1964
 
Future of Web Development
Zeno Rocha
 
MVC Frameworks for building PHP Web Applications
Vforce Infotech
 

Similar to Drupal Module Development (20)

PPT
Advanced Module development
drupalindia
 
PDF
DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalCampDN
 
PDF
DrupalGap. How to create native application for mobile devices based on Drupa...
Alex S
 
ODP
Best Practices For Drupal Developers By Mir Nazim @ Drupal Camp India 2008
Mir Nazim
 
PDF
Drupal 8 - Core and API Changes
Shabir Ahmad
 
PDF
Jaoo - Open Social A Standard For The Social Web
Patrick Chanezon
 
PDF
Django tutorial
Ksd Che
 
PPT
Open social
Tushar Gandhi
 
PPTX
Spring boot
NexThoughts Technologies
 
PPTX
Built to last javascript for enterprise
Marjan Nikolovski
 
PDF
Drupal Module Development
ipsitamishra
 
PDF
Drupal Module Development - OSI Days 2010
Siva Epari
 
PPT
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
Tikal Knowledge
 
PPT
Create a web-app with Cgi Appplication
olegmmiller
 
PDF
Using Drupal Features in B-Translator
Dashamir Hoxha
 
PDF
Advanced Web Scraping or How To Make Internet Your Database #seoplus2018
Esteve Castells
 
PDF
Google Devfest Singapore - OpenSocial
Patrick Chanezon
 
PDF
The State of Front-end At CrowdTwist
Mark Fayngersh
 
PPT
Multi-tenancy with Rails
Paul Gallagher
 
PPT
OpenSocial Intro
Pamela Fox
 
Advanced Module development
drupalindia
 
DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalCampDN
 
DrupalGap. How to create native application for mobile devices based on Drupa...
Alex S
 
Best Practices For Drupal Developers By Mir Nazim @ Drupal Camp India 2008
Mir Nazim
 
Drupal 8 - Core and API Changes
Shabir Ahmad
 
Jaoo - Open Social A Standard For The Social Web
Patrick Chanezon
 
Django tutorial
Ksd Che
 
Open social
Tushar Gandhi
 
Built to last javascript for enterprise
Marjan Nikolovski
 
Drupal Module Development
ipsitamishra
 
Drupal Module Development - OSI Days 2010
Siva Epari
 
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
Tikal Knowledge
 
Create a web-app with Cgi Appplication
olegmmiller
 
Using Drupal Features in B-Translator
Dashamir Hoxha
 
Advanced Web Scraping or How To Make Internet Your Database #seoplus2018
Esteve Castells
 
Google Devfest Singapore - OpenSocial
Patrick Chanezon
 
The State of Front-end At CrowdTwist
Mark Fayngersh
 
Multi-tenancy with Rails
Paul Gallagher
 
OpenSocial Intro
Pamela Fox
 
Ad

Recently uploaded (20)

PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Ad

Drupal Module Development

  • 1. CMS + framework + Community
  • 3. do (drupal_module_development) or die(a_noob); /* Btw.. That is the official title of this talk. */
  • 6. Seek the purpose You got to answer some questions. | a good starting point | What do I want to do?
  • 7. Answers to be found The end user should be able to do this ___________ . __________ be done to the end user. All corollaries of #1 and #2 After all..
  • 9. Lets say we want… This is how user profile page should look like to anybody visiting it. Block displaying currently logged in users “role length” details ** we also want the user to receive ‘n’ number of automated mail notifications as he is approaching a particular role expiry. User account page Member Since: 3weeks 2days Has role ‘lucky’: expires in 13 more days Has role ‘geek’: Never expires BLAH.. BLAH… <Username> Role ‘rookie’: expires in 14 days Role ‘content contributor’: expires in 100 days
  • 10. Some more answers to be found Does the admin need to be bothered? What settings/configurations ought to be exposed to the admin? What is the right place (drupal path) to do this? Okay.. So how should the form(s) look like?
  • 11. Lets say we want…
  • 12. Lets say we want…
  • 13. Try all PnC Highly recommended to evaluate if the requirements can be fulfilled by PnC of drupal core + “killer modules” Drupal core Core – Optional modules Cck, Views, Panels et al
  • 14. Contributions!! Where? How? 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
  • 16. Time to get hands dirty !!  How?
  • 17. 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.
  • 19. Indispensable development help Coder Schema Form Builder Devel
  • 20. Determine the schema Requirement collection starts form the user . Development should start from the database . Map the schema to all/any mock ups you have prepared.
  • 21. Schema mockup role_length rid int rlength int exprid int asg_mail text exp_mail text role_length_user_ roles rid tinyint uid int asg_time timestamp expmail_sent text
  • 22. Map schema to everything else in the UI mockups just created
  • 23. ** we also want the user to receive ‘n’ number of mail notifications as he is approaching a particular role expiry. Check if we have all the data that we need. * Avoid redundancy. There is a lot of data in tables not created by the module being developed. role_length rid int rlength int exprid int asg_mail text exp_mail text role_length_user_roles rid tinyint uid int asg_time timestamp expmail_sent text User account page Member Since: 3weeks 2days Has role ‘lucky’: expires in 13 more days Has role ‘geek’: Never expires BLAH.. BLAH… <Username> Role ‘rookie’: expires in 14 days Role ‘content contributor’: expires in 100 days
  • 24. Creating .info and .install files Use dependencies only when core functionality of your module depends upon other modules ELSE use module_exists() Schema API ? http://api.drupal.org/api/function/hook_install http://api.drupal.org/api/function/hook_uninstall http://api.drupal.org/api/function/hook_install_schema http://api.drupal.org/api/function/hook_schema
  • 25. Creating .module file http://api.drupal.org/api/function/hook_help http://api.drupal.org/api/function/hook_menu Form API ? http://api.drupal.org/api/file/form_api_reference.html/6 http://api.drupal.org/api/function/hook_form_alter AHAH !!
  • 26. Best practices to structure $form Why are they called “best practices” ?
  • 27. How to: dynamic forms and forms that “grow” what is the difference!!??
  • 28. jQuery To jazz up your forms with tool tips, pop-ins, char count et al. AHAH FAPI + menu callback To ajaxify forms without changing the types of or number of elements in the form. (eg: username availability) AHAH FAPI + menu callback + form rebuilding To asynchronously grow the form. Adding/Removing elements or changing types of elements.
  • 29. Changing forms asynchronously Initially requests for the form Build the form > Send out the rendered form > Save form state in the cache Acts upon the AHAH element “ AHAH callback” fetches form from the cache > build it using $_POST values > Add/Removes/Modifies elements > Set the cache > Output changes as JSON AHAH grabs the JSON response and does the magic.
  • 30. 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
  • 31. 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
  • 32. Ain’t Drupal beautiful ?! To keep it that way don’t spit out your output, theme it.
  • 33. Ta-Da!! ® Lets go to node/59
  • 34. http://drupal.org/node/100748 Add code to CVS Create the project on drupal.org Create a release Add a handbook page
  • 35. May the force be with you
  • 36. ? Sumeet Pareek aka WikidKaka positivecharge (at) gmail (dot) com http://sumeetpareek.com http://drupal.org/user/301925