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 <ul><li>The end user should be able to do this ___________ .  </li></ul><ul><li>__________ be done to ...
end user
Lets say we want… This is how  user profile page  should look like to anybody visiting it. Block   displaying currently lo...
Some more answers to be found <ul><li>Does the admin need to be bothered? </li></ul><ul><li>What settings/configurations o...
Lets say we want…
Lets say we want…
Try all PnC <ul><li>Highly recommended  to evaluate if the requirements can be fulfilled by PnC of drupal core + “killer m...
Contributions!! Where? How? <ul><li>There are  very high  chances that what you are looking for has already been developed...
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 ...
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 mockup role_length rid int rlength int exprid int asg_mail text  exp_mail text role_length_user_ roles rid tinyint ...
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...
Creating .info and .install files <ul><li>Use dependencies only when core functionality of your module depends upon other ...
Creating .module file <ul><li>http://api.drupal.org/api/function/hook_help </li></ul><ul><li>http://api.drupal.org/api/fun...
Best practices to structure  $form Why are they called “best practices” ?
How to: dynamic forms and  forms that “grow” what is the difference!!??
<ul><li>jQuery To jazz up your forms with tool tips, pop-ins, char count et al. </li></ul><ul><li>AHAH FAPI + menu callbac...
Changing forms asynchronously Initially requests for the form Build the form > Send out the rendered form > Save form stat...
Major hooks  <ul><li>http://api.drupal.org/api/function/hook_user </li></ul><ul><li>Gotcha:  Not implementing the case del...
Tools we can use… <ul><li>DATABASE API </li></ul><ul><li>http://api.drupal.org/api/function/drupal_write_records </li></ul...
Ain’t Drupal  beautiful ?! To keep it that way don’t spit out your output, theme it.
Ta-Da!! ® Lets go to  node/59
<ul><li>http://drupal.org/node/100748 </li></ul><ul><li>Add code to CVS </li></ul><ul><li>Create the project on drupal.org...
May  the force  be with you
? Sumeet Pareek aka WikidKaka positivecharge (at) gmail (dot) com http://sumeetpareek.com http://drupal.org/user/301925
Upcoming SlideShare
Loading in...5
×

Drupal Module Development

6,391

Published on

How to do custom module development in drupal and contribute it. Explains all the steps including "drupalish" requirement collection best practices, development methodologies etc.

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
6,391
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
190
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide

Drupal Module Development

  1. 1. CMS + framework + Community
  2. 2. Getting Involved!
  3. 3. do (drupal_module_development) or die(a_noob); /* Btw.. That is the official title of this talk. */
  4. 4. Hooks
  5. 5. Drupal API http://api.drupal.org/
  6. 6. Seek the purpose You got to answer some questions. | a good starting point | What do I want to do?
  7. 7. Answers to be found <ul><li>The end user should be able to do this ___________ . </li></ul><ul><li>__________ be done to the end user. </li></ul><ul><li>All corollaries of #1 and #2 </li></ul><ul><li>After all.. </li></ul>
  8. 8. end user
  9. 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. 10. Some more answers to be found <ul><li>Does the admin need to be bothered? </li></ul><ul><li>What settings/configurations ought to be exposed to the admin? </li></ul><ul><li>What is the right place (drupal path) to do this? </li></ul><ul><li>Okay.. So how should the form(s) look like? </li></ul>
  11. 11. Lets say we want…
  12. 12. Lets say we want…
  13. 13. Try all PnC <ul><li>Highly recommended to evaluate if the requirements can be fulfilled by PnC of drupal core + “killer modules” </li></ul><ul><li>Drupal core </li></ul><ul><li>Core – Optional modules </li></ul><ul><li>Cck, Views, Panels et al </li></ul>
  14. 14. Contributions!! Where? How? <ul><li>There are very high chances that what you are looking for has already been developed  </li></ul><ul><li>http://drupal.org/project/Modules </li></ul><ul><li>http://drupalmodules.com/module-finder </li></ul><ul><li>Google -> site:drupal.org/project <search keywords> -cvs </li></ul>
  15. 15. No Luck!!
  16. 16. Time to get hands dirty !!  How?
  17. 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.
  18. 18. Indispensable development help
  19. 19. Indispensable development help Coder Schema Form Builder Devel
  20. 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. 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. 22. Map schema to everything else in the UI mockups just created
  23. 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. 24. Creating .info and .install files <ul><li>Use dependencies only when core functionality of your module depends upon other modules ELSE use module_exists() </li></ul><ul><li>Schema API ? </li></ul><ul><li>http://api.drupal.org/api/function/hook_install </li></ul><ul><li>http://api.drupal.org/api/function/hook_uninstall </li></ul><ul><li>http://api.drupal.org/api/function/hook_install_schema </li></ul><ul><li>http://api.drupal.org/api/function/hook_schema </li></ul>
  25. 25. Creating .module file <ul><li>http://api.drupal.org/api/function/hook_help </li></ul><ul><li>http://api.drupal.org/api/function/hook_menu </li></ul><ul><li>Form API ? </li></ul><ul><li>http://api.drupal.org/api/file/form_api_reference.html/6 </li></ul><ul><li>http://api.drupal.org/api/function/hook_form_alter </li></ul><ul><li>AHAH !! </li></ul>
  26. 26. Best practices to structure $form Why are they called “best practices” ?
  27. 27. How to: dynamic forms and forms that “grow” what is the difference!!??
  28. 28. <ul><li>jQuery To jazz up your forms with tool tips, pop-ins, char count et al. </li></ul><ul><li>AHAH FAPI + menu callback To ajaxify forms without changing the types of or number of elements in the form. (eg: username availability) </li></ul><ul><li>AHAH FAPI + menu callback + form rebuilding To asynchronously grow the form. Adding/Removing elements or changing types of elements. </li></ul>
  29. 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. 30. Major hooks <ul><li>http://api.drupal.org/api/function/hook_user </li></ul><ul><li>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 </li></ul><ul><li>http://api.drupal.org/api/function/hook_cron </li></ul><ul><li>http://api.drupal.org/api/function/hook_block </li></ul>
  31. 31. Tools we can use… <ul><li>DATABASE API </li></ul><ul><li>http://api.drupal.org/api/function/drupal_write_records </li></ul><ul><li>http://api.drupal.org/api/function/user_roles </li></ul><ul><li>http://api.drupal.org/api/function/format_interval </li></ul><ul><li>http://api.drupal.org/api/function/user_multiple_role_edit </li></ul><ul><li>http://api.drupal.org/api/function/user_load </li></ul><ul><li>http://api.drupal.org/api/function/drupal_mail </li></ul><ul><li>http://api.drupal.org/api/function/watchdog </li></ul><ul><li>~ 2200 more </li></ul>
  32. 32. Ain’t Drupal beautiful ?! To keep it that way don’t spit out your output, theme it.
  33. 33. Ta-Da!! ® Lets go to node/59
  34. 34. <ul><li>http://drupal.org/node/100748 </li></ul><ul><li>Add code to CVS </li></ul><ul><li>Create the project on drupal.org </li></ul><ul><li>Create a release </li></ul><ul><li>Add a handbook page </li></ul>
  35. 35. May the force be with you
  36. 36. ? Sumeet Pareek aka WikidKaka positivecharge (at) gmail (dot) com http://sumeetpareek.com http://drupal.org/user/301925
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×