Boutique product development companyIt is amazing what you can accomplish when you have a client-centric team to deliver o...
Drupal6 Module Development Guide         Furqan Razzaq| Drupal Mentor
Drupal6 Module Development GuideTopics covered in the presentation    •   What is Module    •   Collaboration Over Competi...
Drupal6 Module Development GuideWhat is a Module       A module simply is a collection of procedures that are       logica...
Drupal6 Module Development GuideKinds of ModuleThere are three kinds of Drupal Modules1. Core2. Contributes3. Custom      ...
Drupal6 Module Development GuideCore Modules • Core modules are the ones that are shipped with Drupal install and   are ap...
Drupal6 Module Development GuideCustom Module Development• Before we start, following are some helpful links to guide you ...
Drupal6 Module Development GuideCollaboration Over Competition • Module Duplication is a growing concern with in Drupal co...
Drupal6 Module Development GuideLet’s Jump Over Module Development • So, what do you need: • Basic PHP knowledge (of cours...
Drupal6 Module Development GuideLet’s Develop a Single Module • Module Name • Telling Drupal about your module • Declaring...
Drupal6 Module Development GuideGetting Started • Create Following files • .info • .module                                ...
Drupal6 Module Development GuideTelling Drupal About Your Module 1.    How to let Drupal know the module exists? 2.    Dru...
Drupal6 Module Development GuideHow to Let Drupal Know That Module Exists • Tell Drupal about your module in modulename.in...
Drupal6 Module Development GuideTelling Drupal About Your Module 1.    How to let Drupal know the module exists? 2.    Dru...
Drupal6 Module Development GuideDrupal Hooks                                       Drupal Hook???                         ...
Drupal6 Module Development GuideApparently Not • Drupals module system is based on the concept of "hooks". • A hook is a P...
Drupal6 Module Development GuideHow to Declare Hooks? • modulename_hookname() • color_help()                              ...
Drupal6 Module Development GuideWhere/When Hooks are Used?• Drupal determines which modules implement a hook and calls tha...
Drupal6 Module Development GuideCommon Hooks • hook_help() • hook_perm() • hook_init() • hook_theme() • hook_block() • hoo...
Drupal6 Module Development GuideHelp Hooks – a Module File Entry   /**    * Implementation of hook_help    */   function m...
Drupal6 Module Development GuideSpecify the Available Permissions • Tell Drupal who can use your module. /**  * Implementa...
Drupal6 Module Development GuideHook_init () • This hook is run at the beginning of the page request. 1.    Add CSS or JS ...
Drupal6 Module Development GuideCont..Hook_init () function modulename_init() {      $path = drupal_get_path(module, ‘modu...
Drupal6 Module Development GuideHook_Theme ()   function modulename_theme($existing, $type, $theme, $path) {   }   • Write...
Drupal6 Module Development GuideDeclaring Block Content /**       * Implementation of hook_block().       * @param string ...
Drupal6 Module Development GuideDeclaring Block Content Cont..             case view:                $block[subject] = ass...
Drupal6 Module Development Guide Hook Menu• Define menu items and page callbacks.• This hook enables modules to register p...
Drupal6 Module Development GuideHook Menu Cont.. function modulename_menu() {      $items[abc/def] = array(          page ...
Drupal6 Module Development GuideUseful Links   • hook_form_alter(&$form, &$form_state, $form_id)     http://api.drupal.org...
Drupal6 Module Development Guide.Uninstall File    • Remove all tables that a module defines.    • http://api.drupal.org/a...
Drupal6 Module Development GuideUseful Links   1.    Creating modules - a tutorial: Drupal 6.x   2.    Creating Our First ...
Upcoming SlideShare
Loading in …5
×

Ts drupal6 module development v0.2

725 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
725
On SlideShare
0
From Embeds
0
Number of Embeds
28
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Ts drupal6 module development v0.2

  1. 1. Boutique product development companyIt is amazing what you can accomplish when you have a client-centric team to deliver outstanding products.
  2. 2. Drupal6 Module Development Guide Furqan Razzaq| Drupal Mentor
  3. 3. Drupal6 Module Development GuideTopics covered in the presentation • What is Module • Collaboration Over Competition • Telling Drupal About Your Module • Hooks • Block Content • Other Files Furqan Razzaq | Drupal Mentor
  4. 4. Drupal6 Module Development GuideWhat is a Module A module simply is a collection of procedures that are logically combined in a group of files. These procedures can he hooks, menu callbacks, forms, themes or your custom, or even jquery/javascript snippets. Furqan Razzaq | Drupal Mentor
  5. 5. Drupal6 Module Development GuideKinds of ModuleThere are three kinds of Drupal Modules1. Core2. Contributes3. Custom Furqan Razzaq | Drupal Mentor
  6. 6. Drupal6 Module Development GuideCore Modules • Core modules are the ones that are shipped with Drupal install and are approved by the core developers and the community. • The location of these modules is under [installation directory/modules] • There are also a bunch of include files that these modules use. Include files are located under [installation directory/includes] Furqan Razzaq | Drupal Mentor
  7. 7. Drupal6 Module Development GuideCustom Module Development• Before we start, following are some helpful links to guide you through the development process:• http://drupal.org/node/326 [working with Drupal API]• http://api.drupal.org/api/drupal [Drupal API reference]• http://drupal.org/node/7765 [Best Practices on creating and maintaining projects]• http://drupal.org/coding-standards [coding standards]• http://drupal.org/writing-secure-code [writing secure code]We know its a lot to process in one go, but you will get to it eventually. ) Furqan Razzaq | Drupal Mentor
  8. 8. Drupal6 Module Development GuideCollaboration Over Competition • Module Duplication is a growing concern with in Drupal community, which values joining forces on improving one awesome project rather than building several sub-standard ones that overwhelm end users with choices. • So what to do? Search existing modules before you start embarking on your own quest. Furqan Razzaq | Drupal Mentor
  9. 9. Drupal6 Module Development GuideLet’s Jump Over Module Development • So, what do you need: • Basic PHP knowledge (of course ) including syntax and concept of PHP Objects • Basic understanding of database tables, fields, records and SQL statements • A working Drupal installation • Webserver access (in our case, its any set of Apache/PHP/MySql) Furqan Razzaq | Drupal Mentor
  10. 10. Drupal6 Module Development GuideLet’s Develop a Single Module • Module Name • Telling Drupal about your module • Declaring block content Furqan Razzaq | Drupal Mentor
  11. 11. Drupal6 Module Development GuideGetting Started • Create Following files • .info • .module Furqan Razzaq | Drupal Mentor
  12. 12. Drupal6 Module Development GuideTelling Drupal About Your Module 1. How to let Drupal know the module exists? 2. Drupal hook described: hook_help Furqan Razzaq | Drupal Mentor
  13. 13. Drupal6 Module Development GuideHow to Let Drupal Know That Module Exists • Tell Drupal about your module in modulename.info file. File content should be like… • Name (Required) = Color • Description (Required) = Allows the user to change the color scheme of certain themes. • package = Core - optional • Core (Required) = 6.x • version = "6.20" • project = "drupal" • datestamp = "1292447788" Furqan Razzaq | Drupal Mentor
  14. 14. Drupal6 Module Development GuideTelling Drupal About Your Module 1. How to let Drupal know the module exists? 2. Drupal hook described: hook_help Furqan Razzaq | Drupal Mentor
  15. 15. Drupal6 Module Development GuideDrupal Hooks Drupal Hook??? Furqan Razzaq | Drupal Mentor
  16. 16. Drupal6 Module Development GuideApparently Not • Drupals module system is based on the concept of "hooks". • A hook is a PHP function. • Hooks allow modules to interact with the Drupal core. • Each hook has a defined set of parameters and a specified result type. • A module need simply implement a hook. Furqan Razzaq | Drupal Mentor
  17. 17. Drupal6 Module Development GuideHow to Declare Hooks? • modulename_hookname() • color_help() Furqan Razzaq | Drupal Mentor
  18. 18. Drupal6 Module Development GuideWhere/When Hooks are Used?• Drupal determines which modules implement a hook and calls that hook in all enabled modules that implement it. Furqan Razzaq | Drupal Mentor
  19. 19. Drupal6 Module Development GuideCommon Hooks • hook_help() • hook_perm() • hook_init() • hook_theme() • hook_block() • hook_menu() Furqan Razzaq | Drupal Mentor
  20. 20. Drupal6 Module Development GuideHelp Hooks – a Module File Entry /** * Implementation of hook_help */ function modulename_help($path, $arg) { switch ($path) { case admin/help#color: $output = <p>. t(The color module allows a site administrator to quickly and easily change the color scheme of certain themes.’ ).</p>; return $output; } } Furqan Razzaq | Drupal Mentor
  21. 21. Drupal6 Module Development GuideSpecify the Available Permissions • Tell Drupal who can use your module. /** * Implementation of hook_perm */ function modulename_perm() { return array(access site-wide , administer colors); } Furqan Razzaq | Drupal Mentor
  22. 22. Drupal6 Module Development GuideHook_init () • This hook is run at the beginning of the page request. 1. Add CSS or JS that should be present on every page. 2. Set up global parameters which are needed later in the request Furqan Razzaq | Drupal Mentor
  23. 23. Drupal6 Module Development GuideCont..Hook_init () function modulename_init() { $path = drupal_get_path(module, ‘modulename); drupal_add_js($path . /filename.js); drupal_add_css($path . ‘/filename.css, module, all, FALSE); } http://api.drupal.org/api/drupal/developer!hooks!core.php/function/hook_i nit/6 Furqan Razzaq | Drupal Mentor
  24. 24. Drupal6 Module Development GuideHook_Theme () function modulename_theme($existing, $type, $theme, $path) { } • Write theme funtions Furqan Razzaq | Drupal Mentor
  25. 25. Drupal6 Module Development GuideDeclaring Block Content /** * Implementation of hook_block(). * @param string $op one of "list", "view", "save" and "configure" * @param integer $delta code to identify the block * @param array $edit only for "save" operation */ function modulename_block($op = list, $delta = 0, $edit = array()) { switch ($op) { case list: $block = array(); $block[0]["info"] = t(assets); return $block; break; Furqan Razzaq | Drupal Mentor
  26. 26. Drupal6 Module Development GuideDeclaring Block Content Cont.. case view: $block[subject] = assets; $block[content] = get_block_content(); return $block; break; } } http://api.drupal.org/api/drupal/developer!hooks!core.php/function/hook_ block/6 Furqan Razzaq | Drupal Mentor
  27. 27. Drupal6 Module Development Guide Hook Menu• Define menu items and page callbacks.• This hook enables modules to register paths in order to define how URL requests are handled.• This hook is rarely called (for example, when modules are enabled), and its results are cached in the database. Furqan Razzaq | Drupal Mentor
  28. 28. Drupal6 Module Development GuideHook Menu Cont.. function modulename_menu() { $items[abc/def] = array( page callback => mymodule_abc_view, type => MENU_CALLBACK, access callback => true, ); return $items; } http://api.drupal.org/api/drupal/developer!hooks!core.php/function/hook_ menu/6 Furqan Razzaq | Drupal Mentor
  29. 29. Drupal6 Module Development GuideUseful Links • hook_form_alter(&$form, &$form_state, $form_id) http://api.drupal.org/api/drupal/developer!hooks!core.ph p/function/hook_form_alter/6 • hook_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) http://api.drupal.org/api/drupal/developer!hooks!core.ph p/function/hook_nodeapi/6 • hook_user($op, &$edit, &$account, $category = NULL) http://api.drupal.org/api/drupal/developer!hooks!core.ph p/function/hook_user/6 Furqan Razzaq | Drupal Mentor
  30. 30. Drupal6 Module Development Guide.Uninstall File • Remove all tables that a module defines. • http://api.drupal.org/api/drupal/includes!common.inc/function/drupal_ uninstall_schema/6 Furqan Razzaq | Drupal Mentor
  31. 31. Drupal6 Module Development GuideUseful Links 1. Creating modules - a tutorial: Drupal 6.x 2. Creating Our First Module (1.3M PDF) 3. Coding standards 4. http://www.drupal.org Furqan Razzaq | Drupal Mentor

×