SlideShare une entreprise Scribd logo
1  sur  31
Télécharger pour lire hors ligne
Boutique product development company
It is amazing what you can accomplish when you have a client-centric team to deliver outstanding products.
Drupal6 Module Development Guide
         Furqan Razzaq| Drupal Mentor
Drupal6 Module Development Guide
Topics covered in the presentation




    •   What is Module
    •   Collaboration Over Competition
    •   Telling Drupal About Your
        Module
    •   Hooks
    •   Block Content
    •   Other Files



                                         Furqan Razzaq | Drupal Mentor
Drupal6 Module Development Guide

What 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
Drupal6 Module Development Guide

Kinds of Module

There are three kinds of Drupal Modules
1. Core
2. Contributes
3. Custom




                                          Furqan Razzaq | Drupal Mentor
Drupal6 Module Development Guide

Core 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
Drupal6 Module Development Guide

Custom 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
Drupal6 Module Development Guide

Collaboration 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
Drupal6 Module Development Guide

Let’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
Drupal6 Module Development Guide

Let’s Develop a Single Module

 • Module Name

 • Telling Drupal about your module

 • Declaring block content




                                      Furqan Razzaq | Drupal Mentor
Drupal6 Module Development Guide

Getting Started

 • Create Following files

 • .info

 • .module




                                   Furqan Razzaq | Drupal Mentor
Drupal6 Module Development Guide

Telling Drupal About Your Module

 1.    How to let Drupal know the module exists?

 2.    Drupal hook described: hook_help




                                                   Furqan Razzaq | Drupal Mentor
Drupal6 Module Development Guide

How 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
Drupal6 Module Development Guide

Telling Drupal About Your Module

 1.    How to let Drupal know the module exists?

 2.    Drupal hook described: hook_help




                                                   Furqan Razzaq | Drupal Mentor
Drupal6 Module Development Guide

Drupal Hooks


                                       Drupal Hook???




                                   Furqan Razzaq | Drupal Mentor
Drupal6 Module Development Guide

Apparently Not

 • Drupal's 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
Drupal6 Module Development Guide

How to Declare Hooks?

 • modulename_hookname()
 • color_help()




                                   Furqan Razzaq | Drupal Mentor
Drupal6 Module Development Guide

Where/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
Drupal6 Module Development Guide

Common Hooks

 • hook_help()
 • hook_perm()
 • hook_init()
 • hook_theme()
 • hook_block()
 • hook_menu()




                                   Furqan Razzaq | Drupal Mentor
Drupal6 Module Development Guide

Help 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
Drupal6 Module Development Guide

Specify 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
Drupal6 Module Development Guide

Hook_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
Drupal6 Module Development Guide

Cont..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
Drupal6 Module Development Guide

Hook_Theme ()


   function modulename_theme($existing, $type, $theme, $path) {
   }
   • Write theme funtions




                                               Furqan Razzaq | Drupal Mentor
Drupal6 Module Development Guide

Declaring 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
Drupal6 Module Development Guide

Declaring 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
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
Drupal6 Module Development Guide

Hook 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
Drupal6 Module Development Guide

Useful 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
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
Drupal6 Module Development Guide

Useful 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

Contenu connexe

Tendances

Getting started with drupal 8 code
Getting started with drupal 8 codeGetting started with drupal 8 code
Getting started with drupal 8 codeForum One
 
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...Phase2
 
Drupal 8 theming deep dive
Drupal 8 theming deep diveDrupal 8 theming deep dive
Drupal 8 theming deep diveRomain Jarraud
 
Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009Emma Jane Hogbin Westby
 
drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010Florian Latzel
 
Drupal 6.x, Drupal 7.x -- Scratching the surface
Drupal 6.x, Drupal 7.x -- Scratching the surfaceDrupal 6.x, Drupal 7.x -- Scratching the surface
Drupal 6.x, Drupal 7.x -- Scratching the surfaceFlorian Latzel
 
Absolute Beginners Guide to Drupal
Absolute Beginners Guide to DrupalAbsolute Beginners Guide to Drupal
Absolute Beginners Guide to DrupalRod Martin
 
Drush und Multisite: drush_multi
Drush und Multisite: drush_multiDrush und Multisite: drush_multi
Drush und Multisite: drush_multiFlorian Latzel
 
Becoming A Drupal Master Builder
Becoming A Drupal Master BuilderBecoming A Drupal Master Builder
Becoming A Drupal Master BuilderPhilip Norton
 
Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016
Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016
Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016Paul McKibben
 
Yet Another Drupal Development/Deployment Presentation
Yet Another Drupal Development/Deployment PresentationYet Another Drupal Development/Deployment Presentation
Yet Another Drupal Development/Deployment Presentationdigital006
 
Automating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyondAutomating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyondNuvole
 
8 things to know about theming in drupal 8
8 things to know about theming in drupal 88 things to know about theming in drupal 8
8 things to know about theming in drupal 8Logan Farr
 
Plain english guide to drupal 8 criticals
Plain english guide to drupal 8 criticalsPlain english guide to drupal 8 criticals
Plain english guide to drupal 8 criticalsAngela Byron
 
Building and Maintaining a Distribution in Drupal 7 with Features
Building and Maintaining a  Distribution in Drupal 7 with FeaturesBuilding and Maintaining a  Distribution in Drupal 7 with Features
Building and Maintaining a Distribution in Drupal 7 with FeaturesNuvole
 
Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Drupalcon Paris
 

Tendances (20)

Getting started with drupal 8 code
Getting started with drupal 8 codeGetting started with drupal 8 code
Getting started with drupal 8 code
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
features+
features+features+
features+
 
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
 
Drupal 8 theming deep dive
Drupal 8 theming deep diveDrupal 8 theming deep dive
Drupal 8 theming deep dive
 
Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009
 
drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010
 
Drupal 6.x, Drupal 7.x -- Scratching the surface
Drupal 6.x, Drupal 7.x -- Scratching the surfaceDrupal 6.x, Drupal 7.x -- Scratching the surface
Drupal 6.x, Drupal 7.x -- Scratching the surface
 
Absolute Beginners Guide to Drupal
Absolute Beginners Guide to DrupalAbsolute Beginners Guide to Drupal
Absolute Beginners Guide to Drupal
 
Drush und Multisite: drush_multi
Drush und Multisite: drush_multiDrush und Multisite: drush_multi
Drush und Multisite: drush_multi
 
Migrate to Drupal 8
Migrate to Drupal 8Migrate to Drupal 8
Migrate to Drupal 8
 
Becoming A Drupal Master Builder
Becoming A Drupal Master BuilderBecoming A Drupal Master Builder
Becoming A Drupal Master Builder
 
Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016
Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016
Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016
 
Drupal Front End PHP
Drupal Front End PHPDrupal Front End PHP
Drupal Front End PHP
 
Yet Another Drupal Development/Deployment Presentation
Yet Another Drupal Development/Deployment PresentationYet Another Drupal Development/Deployment Presentation
Yet Another Drupal Development/Deployment Presentation
 
Automating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyondAutomating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyond
 
8 things to know about theming in drupal 8
8 things to know about theming in drupal 88 things to know about theming in drupal 8
8 things to know about theming in drupal 8
 
Plain english guide to drupal 8 criticals
Plain english guide to drupal 8 criticalsPlain english guide to drupal 8 criticals
Plain english guide to drupal 8 criticals
 
Building and Maintaining a Distribution in Drupal 7 with Features
Building and Maintaining a  Distribution in Drupal 7 with FeaturesBuilding and Maintaining a  Distribution in Drupal 7 with Features
Building and Maintaining a Distribution in Drupal 7 with Features
 
Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3
 

Similaire à Ts drupal6 module development v0.2

Gajendra sharma Drupal Module development
Gajendra sharma Drupal Module developmentGajendra sharma Drupal Module development
Gajendra sharma Drupal Module developmentGajendra Sharma
 
Drupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First StepsDrupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First StepsLuís Carneiro
 
DrupalCon LA 2015 Review
DrupalCon LA 2015 ReviewDrupalCon LA 2015 Review
DrupalCon LA 2015 ReviewlittleMAS
 
Making The Drupal Pill Easier To Swallow
Making The Drupal Pill Easier To SwallowMaking The Drupal Pill Easier To Swallow
Making The Drupal Pill Easier To SwallowPhilip Norton
 
Drupal module development training delhi
Drupal module development training delhiDrupal module development training delhi
Drupal module development training delhiunitedwebsoft
 
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
 
Your first d8 module
Your first d8 moduleYour first d8 module
Your first d8 moduletedbow
 
Getting Started with Drupal - Handouts
Getting Started with Drupal - HandoutsGetting Started with Drupal - Handouts
Getting Started with Drupal - HandoutsRachel Vacek
 
Building a Drupal Distribution using Features, Drush Make, Installation Profi...
Building a Drupal Distribution using Features, Drush Make, Installation Profi...Building a Drupal Distribution using Features, Drush Make, Installation Profi...
Building a Drupal Distribution using Features, Drush Make, Installation Profi...Ben Shell
 
Rapid site production with Drupal
Rapid site production with DrupalRapid site production with Drupal
Rapid site production with DrupalRob Sawyer
 
Drupal 6-performance-tips-slideshare
Drupal 6-performance-tips-slideshareDrupal 6-performance-tips-slideshare
Drupal 6-performance-tips-slideshareTrevor James
 
Drush to simplify Drupalers work - Sivaji
Drush to simplify Drupalers work - SivajiDrush to simplify Drupalers work - Sivaji
Drush to simplify Drupalers work - SivajiDrupal Camp Delhi
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module developmentRachit Gupta
 
LITA Preconference: Getting Started with Drupal (handout)
LITA Preconference: Getting Started with Drupal (handout)LITA Preconference: Getting Started with Drupal (handout)
LITA Preconference: Getting Started with Drupal (handout)Rachel Vacek
 
Doing Drupal security right from Drupalcon London
Doing Drupal security right from Drupalcon LondonDoing Drupal security right from Drupalcon London
Doing Drupal security right from Drupalcon LondonGábor Hojtsy
 
Doing Drupal security right
Doing Drupal security rightDoing Drupal security right
Doing Drupal security rightGábor Hojtsy
 
Introduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesIntroduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesGerald Villorente
 

Similaire à Ts drupal6 module development v0.2 (20)

Gajendra sharma Drupal Module development
Gajendra sharma Drupal Module developmentGajendra sharma Drupal Module development
Gajendra sharma Drupal Module development
 
Drupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First StepsDrupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First Steps
 
DrupalCon LA 2015 Review
DrupalCon LA 2015 ReviewDrupalCon LA 2015 Review
DrupalCon LA 2015 Review
 
Making The Drupal Pill Easier To Swallow
Making The Drupal Pill Easier To SwallowMaking The Drupal Pill Easier To Swallow
Making The Drupal Pill Easier To Swallow
 
Drupal module development training delhi
Drupal module development training delhiDrupal module development training delhi
Drupal module development training delhi
 
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
 
Your first d8 module
Your first d8 moduleYour first d8 module
Your first d8 module
 
Welcome aboard the team
Welcome aboard the teamWelcome aboard the team
Welcome aboard the team
 
Getting Started with Drupal - Handouts
Getting Started with Drupal - HandoutsGetting Started with Drupal - Handouts
Getting Started with Drupal - Handouts
 
Building a Drupal Distribution using Features, Drush Make, Installation Profi...
Building a Drupal Distribution using Features, Drush Make, Installation Profi...Building a Drupal Distribution using Features, Drush Make, Installation Profi...
Building a Drupal Distribution using Features, Drush Make, Installation Profi...
 
Rapid site production with Drupal
Rapid site production with DrupalRapid site production with Drupal
Rapid site production with Drupal
 
Drupal Skils Lab 302Labs
Drupal Skils Lab 302Labs Drupal Skils Lab 302Labs
Drupal Skils Lab 302Labs
 
Drupal 6-performance-tips-slideshare
Drupal 6-performance-tips-slideshareDrupal 6-performance-tips-slideshare
Drupal 6-performance-tips-slideshare
 
Drush to simplify Drupalers work - Sivaji
Drush to simplify Drupalers work - SivajiDrush to simplify Drupalers work - Sivaji
Drush to simplify Drupalers work - Sivaji
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module development
 
LITA Preconference: Getting Started with Drupal (handout)
LITA Preconference: Getting Started with Drupal (handout)LITA Preconference: Getting Started with Drupal (handout)
LITA Preconference: Getting Started with Drupal (handout)
 
Drupal in-depth
Drupal in-depthDrupal in-depth
Drupal in-depth
 
Doing Drupal security right from Drupalcon London
Doing Drupal security right from Drupalcon LondonDoing Drupal security right from Drupalcon London
Doing Drupal security right from Drupalcon London
 
Doing Drupal security right
Doing Drupal security rightDoing Drupal security right
Doing Drupal security right
 
Introduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesIntroduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, Terminologies
 

Plus de Confiz

Agile training workshop
Agile training workshopAgile training workshop
Agile training workshopConfiz
 
Web services with laravel
Web services with laravelWeb services with laravel
Web services with laravelConfiz
 
DMAIC-Six sigma process Improvement Approach
DMAIC-Six sigma process Improvement ApproachDMAIC-Six sigma process Improvement Approach
DMAIC-Six sigma process Improvement ApproachConfiz
 
What is UFT? HP's unified functional testing.
What is UFT? HP's unified functional testing.What is UFT? HP's unified functional testing.
What is UFT? HP's unified functional testing.Confiz
 
Software testing methods, levels and types
Software testing methods, levels and typesSoftware testing methods, levels and types
Software testing methods, levels and typesConfiz
 
Sqa, test scenarios and test cases
Sqa, test scenarios and test casesSqa, test scenarios and test cases
Sqa, test scenarios and test casesConfiz
 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo designConfiz
 
Entity framework code first
Entity framework code firstEntity framework code first
Entity framework code firstConfiz
 
Security testing presentation
Security testing presentationSecurity testing presentation
Security testing presentationConfiz
 
Ts seo t ech session
Ts   seo t ech sessionTs   seo t ech session
Ts seo t ech sessionConfiz
 
Learning as a creative professional
Learning as a creative professionalLearning as a creative professional
Learning as a creative professionalConfiz
 
Learning as a creative professional
Learning as a creative professionalLearning as a creative professional
Learning as a creative professionalConfiz
 
Ts archiving
Ts   archivingTs   archiving
Ts archivingConfiz
 
Advance text rendering in i os
Advance text rendering in i osAdvance text rendering in i os
Advance text rendering in i osConfiz
 
Ts threading
Ts   threadingTs   threading
Ts threadingConfiz
 
Ts android supporting multiple screen
Ts   android supporting multiple screenTs   android supporting multiple screen
Ts android supporting multiple screenConfiz
 
Photoshop manners
Photoshop mannersPhotoshop manners
Photoshop mannersConfiz
 
Monkey talk
Monkey talkMonkey talk
Monkey talkConfiz
 
An insight to microsoft platform
An insight to microsoft platformAn insight to microsoft platform
An insight to microsoft platformConfiz
 
Ts branching over the top
Ts   branching over the topTs   branching over the top
Ts branching over the topConfiz
 

Plus de Confiz (20)

Agile training workshop
Agile training workshopAgile training workshop
Agile training workshop
 
Web services with laravel
Web services with laravelWeb services with laravel
Web services with laravel
 
DMAIC-Six sigma process Improvement Approach
DMAIC-Six sigma process Improvement ApproachDMAIC-Six sigma process Improvement Approach
DMAIC-Six sigma process Improvement Approach
 
What is UFT? HP's unified functional testing.
What is UFT? HP's unified functional testing.What is UFT? HP's unified functional testing.
What is UFT? HP's unified functional testing.
 
Software testing methods, levels and types
Software testing methods, levels and typesSoftware testing methods, levels and types
Software testing methods, levels and types
 
Sqa, test scenarios and test cases
Sqa, test scenarios and test casesSqa, test scenarios and test cases
Sqa, test scenarios and test cases
 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo design
 
Entity framework code first
Entity framework code firstEntity framework code first
Entity framework code first
 
Security testing presentation
Security testing presentationSecurity testing presentation
Security testing presentation
 
Ts seo t ech session
Ts   seo t ech sessionTs   seo t ech session
Ts seo t ech session
 
Learning as a creative professional
Learning as a creative professionalLearning as a creative professional
Learning as a creative professional
 
Learning as a creative professional
Learning as a creative professionalLearning as a creative professional
Learning as a creative professional
 
Ts archiving
Ts   archivingTs   archiving
Ts archiving
 
Advance text rendering in i os
Advance text rendering in i osAdvance text rendering in i os
Advance text rendering in i os
 
Ts threading
Ts   threadingTs   threading
Ts threading
 
Ts android supporting multiple screen
Ts   android supporting multiple screenTs   android supporting multiple screen
Ts android supporting multiple screen
 
Photoshop manners
Photoshop mannersPhotoshop manners
Photoshop manners
 
Monkey talk
Monkey talkMonkey talk
Monkey talk
 
An insight to microsoft platform
An insight to microsoft platformAn insight to microsoft platform
An insight to microsoft platform
 
Ts branching over the top
Ts   branching over the topTs   branching over the top
Ts branching over the top
 

Ts drupal6 module development v0.2

  • 1. Boutique product development company It is amazing what you can accomplish when you have a client-centric team to deliver outstanding products.
  • 2. Drupal6 Module Development Guide Furqan Razzaq| Drupal Mentor
  • 3. Drupal6 Module Development Guide Topics 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. Drupal6 Module Development Guide What 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. Drupal6 Module Development Guide Kinds of Module There are three kinds of Drupal Modules 1. Core 2. Contributes 3. Custom Furqan Razzaq | Drupal Mentor
  • 6. Drupal6 Module Development Guide Core 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. Drupal6 Module Development Guide Custom 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. Drupal6 Module Development Guide Collaboration 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. Drupal6 Module Development Guide Let’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. Drupal6 Module Development Guide Let’s Develop a Single Module • Module Name • Telling Drupal about your module • Declaring block content Furqan Razzaq | Drupal Mentor
  • 11. Drupal6 Module Development Guide Getting Started • Create Following files • .info • .module Furqan Razzaq | Drupal Mentor
  • 12. Drupal6 Module Development Guide Telling Drupal About Your Module 1. How to let Drupal know the module exists? 2. Drupal hook described: hook_help Furqan Razzaq | Drupal Mentor
  • 13. Drupal6 Module Development Guide How 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. Drupal6 Module Development Guide Telling Drupal About Your Module 1. How to let Drupal know the module exists? 2. Drupal hook described: hook_help Furqan Razzaq | Drupal Mentor
  • 15. Drupal6 Module Development Guide Drupal Hooks Drupal Hook??? Furqan Razzaq | Drupal Mentor
  • 16. Drupal6 Module Development Guide Apparently Not • Drupal's 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. Drupal6 Module Development Guide How to Declare Hooks? • modulename_hookname() • color_help() Furqan Razzaq | Drupal Mentor
  • 18. Drupal6 Module Development Guide Where/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. Drupal6 Module Development Guide Common Hooks • hook_help() • hook_perm() • hook_init() • hook_theme() • hook_block() • hook_menu() Furqan Razzaq | Drupal Mentor
  • 20. Drupal6 Module Development Guide Help 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. Drupal6 Module Development Guide Specify 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. Drupal6 Module Development Guide Hook_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. Drupal6 Module Development Guide Cont..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. Drupal6 Module Development Guide Hook_Theme () function modulename_theme($existing, $type, $theme, $path) { } • Write theme funtions Furqan Razzaq | Drupal Mentor
  • 25. Drupal6 Module Development Guide Declaring 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. Drupal6 Module Development Guide Declaring 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. 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. Drupal6 Module Development Guide Hook 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. Drupal6 Module Development Guide Useful 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. 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. Drupal6 Module Development Guide Useful 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