SlideShare a Scribd company logo
1 of 14
Download to read offline
Advanced Module
Development (D6)

Case study: UC_Etranzact Ubercart
         contrib module

                       Kayode Odeyemi
             Technical Architect, Opevel
               DrupalCamp Lagos 2011
Where to start from?

There are various ways of starting a Drupal
module;

• Using Features module: Makes your Drupal
  module exportable and deployment easier.

• Using Module Builder module: auto-generates a
  skeleton or "scaffolding" for a module
Drupal Common Hooks

•   Hook_menu
•   Hook_init
•   Hook_help
•   Hook_nodeapi
•   Hook_theme
•   Hook_install
•   Hook_uninstall
•   Hook_form
•   Hook_form_alter
•   Hook_form_submit
•   Hook_form_validate
Very useful Drupal APIs for everyday development
 •   Module_invoke
 •   Module_load_include
 •   Drupal_write_record
 •   Function_exists
 •   Call_user_func_array
 •   Db_table_exists
 •   Db_query
 •   Db_result
 •   Db_object_fetch_array and db_object_fetch_object
 •   Drupal_set_message or dsm if using devel module
 •   Db_create_table
 •   Update_sql
 •   Views_get_views_result
 •   Db_add_field
 •   Db_drop_field
 •   Drupal_get_schema
 •   Element_children
 •   Views_get_default_view
Writing Drupal Hooks
There are different ways of writing Drupal hooks.

// Using module_implements inline within a non-hook function and using module_invoke

foreach(module_implements(‘hook_name') as $module) {
   module_invoke($module, ‘hook_name', $args);
}

// Explicitly writing the hook as a function with module_implements alone
function mymodule_hook($fees) {
   foreach (module_implements(‘hook_name') as $module) {
      $function = $module . '_hook_name';
      $result = $function($fees);
      if (isset($result) && is_array($result)) {
          $return = array_merge($return, $result);
      }
      else if (isset($result)) {
          $return[] = $result;
      }
   }
   return $return;
}
drupal_http_request: Drupal's simple curl equivalent
  // curl
  $curl = curl_init(); $apiurl =
    variable_get('uc_etranzact_demo_mode', 1) ?
    UC_ETRANZACT_SERVICE_DEMO :
    UC_ETRANZACT_SERVICE; $apiurl = sprintf('%s?%s',
    $apiurl, $query); curl_setopt($curl, CURLOPT_URL,
    $apiurl); curl_setopt($curl,
    CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl,
    CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl,
    CURLOPT_FOLLOWLOCATION, 1); $return =
    curl_exec($curl);

  // drupal_http_request
  $result = drupal_http_request($uri, $header, $method,
    http_build_query($data, '', '&'));
Test with SimpleTest
  • When your project is starting to get robust and clumsy, test with
    SimpleTest
  • Common SimpleTest APIs are:

     – drupalGetNodeByTitle($title)
     – drupalCreateNode($settings)
     – drupalCreateContentType($settings) -
       drupalCreateUser($permissions)
     – checkPermissions(array $permissions, $reset = FALSE): Check
       to make sure that the array of permissions are valid.
     – drupalLogin(stdClass $user): Log in a user with the internal
       browser.
Test with SimpleTest

     – drupalLogout

     – assertNotEqual: Check to see if two values are not equal.

     – assertEqual: Check to see if two values are equal.

     – drupalPost: Execute a POST request on a Drupal page.

     – drupalGet: Retrieves a Drupal path or an absolute path.

     – assertTrue: Check to see if a value is not false (not an empty
       string, 0, NULL, or FALSE)

     – assertFalse: Check to see if a value is false (an empty string, 0,
       NULL, or FALSE).

     – assertNull: Check to see if a value is not NULL.
Administer Drupal faster with Drupal
  •   Drush is Drupal’s CLI language
  •   Administer modules quickly with Drush
  •   When working with multi-sites, Drush is your best friend
  •   Drupal cheat sheet

      –   Drush status
      –   Drush dl <modulename>
      –   Drush cc
      –   Drush eval “<php code>”
      –   Drush en <module name>
      –   Drush dis <module name>
      –   Drush up
      –   Drush upc <module name>
      –   … more on drupal.org
Debugging Drupal

• The devel module and theme developer modules are
  very handy tools for Debugging Drupal.

• There’s also a firebug Drupal extension for debugging
  Drupal

• Useful functions:
   – Dsm
   – Dpr
   – dvm
Ubercart Payment Hooks and useful APIs
• Hook_payment_method: define a custom payment method
• Hook_order: define and process the order items
• Hook_checkout_pane: define a custom pane for your order and
  style it
• uc_order_status_data: Check the status of an order
• uc_cart_empty(uc_cart_get_id()): Empty a cart
• uc_order_save($order): save an order to the database
• Hook_tapir_table_alter
• Hook_cart_item: alter the items in cart
• Hook_cart_pane: Override the cart pane
• Hook_product_description: modify the descriptions of items in cart
• Uc_cart_get_contents: get cart contents
Understanding ubercart cart process

 • Add items to cart using uc_cart_add_items.

 • Checkout your order and implement
   hook_checkout_pane to customize the order
   items.

 • Review the order in different states namely:
    – New: only called if the order is new
    – Submit: Process the order such as integrating with a
      payment gateway like etranzact.
    – Save: Save your order in a database
    – Load: called immediately an order is successfully
      saved in the db
How we build it: uc_etranzact module


 • Uc_etranzact module only requires a payment
   gateway implementation

 • Ubercart Hooks that got the job done:
    – Hook_payment_gateway
    – Hook_order
    – Callback functions to process the order to
      integrate with etranzact system
Questions
  • Website      - http://opevel.com

  • Twitter : @opevel @drupal @acquia

  • Opevel Services

     – Drupal custom development

     – Drupal site architecture

     – Custom Application Development on Google App Engine


  http://drupal.org/sandbox/charyorde/1310706

  • Datasphir is hiring Drupal developers. – http://datasphir.com

More Related Content

What's hot

DSpace UI Prototype Challenge: Spring Boot + Thymeleaf
DSpace UI Prototype Challenge: Spring Boot + ThymeleafDSpace UI Prototype Challenge: Spring Boot + Thymeleaf
DSpace UI Prototype Challenge: Spring Boot + ThymeleafTim Donohue
 
Here Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPressHere Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPressRami Sayar
 
Multi Tenancy With Python and Django
Multi Tenancy With Python and DjangoMulti Tenancy With Python and Django
Multi Tenancy With Python and Djangoscottcrespo
 
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Campmodern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet CampPuppet
 
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...Sencha
 
Choosing a Javascript Framework
Choosing a Javascript FrameworkChoosing a Javascript Framework
Choosing a Javascript FrameworkAll Things Open
 
Build Your Own CMS with Apache Sling
Build Your Own CMS with Apache SlingBuild Your Own CMS with Apache Sling
Build Your Own CMS with Apache SlingBob Paulin
 
JavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User ExperienceJavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User Experiencereeder29
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Ryan Weaver
 
RESTful Web Applications with Apache Sling
RESTful Web Applications with Apache SlingRESTful Web Applications with Apache Sling
RESTful Web Applications with Apache SlingBertrand Delacretaz
 
IBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the BoxIBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the BoxKarl-Henry Martinsson
 
SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...
SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...
SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...Anusha Chickermane
 
Convert modules from 6.x to 7.x
Convert modules from 6.x to 7.xConvert modules from 6.x to 7.x
Convert modules from 6.x to 7.xJoão Ventura
 
OSGi, Scripting and REST, Building Webapps With Apache Sling
OSGi, Scripting and REST, Building Webapps With Apache SlingOSGi, Scripting and REST, Building Webapps With Apache Sling
OSGi, Scripting and REST, Building Webapps With Apache SlingCarsten Ziegeler
 
Pure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkPure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkBryan Ollendyke
 
Node.js and couchbase Full Stack JSON - Munich NoSQL
Node.js and couchbase   Full Stack JSON - Munich NoSQLNode.js and couchbase   Full Stack JSON - Munich NoSQL
Node.js and couchbase Full Stack JSON - Munich NoSQLPhilipp Fehre
 
High Performance Drupal
High Performance DrupalHigh Performance Drupal
High Performance DrupalJeff Geerling
 

What's hot (20)

DSpace UI Prototype Challenge: Spring Boot + Thymeleaf
DSpace UI Prototype Challenge: Spring Boot + ThymeleafDSpace UI Prototype Challenge: Spring Boot + Thymeleaf
DSpace UI Prototype Challenge: Spring Boot + Thymeleaf
 
Here Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPressHere Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPress
 
Multi Tenancy With Python and Django
Multi Tenancy With Python and DjangoMulti Tenancy With Python and Django
Multi Tenancy With Python and Django
 
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Campmodern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
 
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
 
JSP Part 2
JSP Part 2JSP Part 2
JSP Part 2
 
Choosing a Javascript Framework
Choosing a Javascript FrameworkChoosing a Javascript Framework
Choosing a Javascript Framework
 
Build Your Own CMS with Apache Sling
Build Your Own CMS with Apache SlingBuild Your Own CMS with Apache Sling
Build Your Own CMS with Apache Sling
 
JavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User ExperienceJavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User Experience
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
 
RESTful Web Applications with Apache Sling
RESTful Web Applications with Apache SlingRESTful Web Applications with Apache Sling
RESTful Web Applications with Apache Sling
 
AD102 - Break out of the Box
AD102 - Break out of the BoxAD102 - Break out of the Box
AD102 - Break out of the Box
 
Break out of The Box - Part 2
Break out of The Box - Part 2Break out of The Box - Part 2
Break out of The Box - Part 2
 
IBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the BoxIBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the Box
 
SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...
SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...
SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...
 
Convert modules from 6.x to 7.x
Convert modules from 6.x to 7.xConvert modules from 6.x to 7.x
Convert modules from 6.x to 7.x
 
OSGi, Scripting and REST, Building Webapps With Apache Sling
OSGi, Scripting and REST, Building Webapps With Apache SlingOSGi, Scripting and REST, Building Webapps With Apache Sling
OSGi, Scripting and REST, Building Webapps With Apache Sling
 
Pure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkPure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talk
 
Node.js and couchbase Full Stack JSON - Munich NoSQL
Node.js and couchbase   Full Stack JSON - Munich NoSQLNode.js and couchbase   Full Stack JSON - Munich NoSQL
Node.js and couchbase Full Stack JSON - Munich NoSQL
 
High Performance Drupal
High Performance DrupalHigh Performance Drupal
High Performance Drupal
 

Viewers also liked

Top 10 preso
Top 10 presoTop 10 preso
Top 10 presoOpevel
 
Showcasing drupal
Showcasing drupalShowcasing drupal
Showcasing drupalOpevel
 
Opevel social-enterprise-platform osep-google_apps_slideshare
Opevel social-enterprise-platform osep-google_apps_slideshareOpevel social-enterprise-platform osep-google_apps_slideshare
Opevel social-enterprise-platform osep-google_apps_slideshareOpevel
 
Interoperability betweendrupalandgoogleapps
Interoperability betweendrupalandgoogleappsInteroperability betweendrupalandgoogleapps
Interoperability betweendrupalandgoogleappsOpevel
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with DataSeth Familian
 
3 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 20173 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 2017Drift
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheLeslie Samuel
 

Viewers also liked (7)

Top 10 preso
Top 10 presoTop 10 preso
Top 10 preso
 
Showcasing drupal
Showcasing drupalShowcasing drupal
Showcasing drupal
 
Opevel social-enterprise-platform osep-google_apps_slideshare
Opevel social-enterprise-platform osep-google_apps_slideshareOpevel social-enterprise-platform osep-google_apps_slideshare
Opevel social-enterprise-platform osep-google_apps_slideshare
 
Interoperability betweendrupalandgoogleapps
Interoperability betweendrupalandgoogleappsInteroperability betweendrupalandgoogleapps
Interoperability betweendrupalandgoogleapps
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with Data
 
3 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 20173 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 2017
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
 

Similar to Advanced moduledevelopment d6_slideshare

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
 
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
 
Learning the basics of the Drupal API
Learning the basics of the Drupal APILearning the basics of the Drupal API
Learning the basics of the Drupal APIAlexandru Badiu
 
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
 
Drupal Module Development - OSI Days 2010
Drupal Module Development - OSI Days 2010Drupal Module Development - OSI Days 2010
Drupal Module Development - OSI Days 2010Siva Epari
 
Drupal Module Development
Drupal Module DevelopmentDrupal Module Development
Drupal Module Developmentipsitamishra
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practicesmanugoel2003
 
Staying Sane with Drupal (A Develper's Survival Guide)
Staying Sane with Drupal (A Develper's Survival Guide)Staying Sane with Drupal (A Develper's Survival Guide)
Staying Sane with Drupal (A Develper's Survival Guide)Oscar Merida
 
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...LEDC 2016
 
Migrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindMigrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindValentine Matsveiko
 
Working with LoopBack Models
Working with LoopBack ModelsWorking with LoopBack Models
Working with LoopBack ModelsRaymond Feng
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)arcware
 
Views Style Plugins
Views Style PluginsViews Style Plugins
Views Style Pluginsmwrather
 
Drupal Javascript for developers
Drupal Javascript for developersDrupal Javascript for developers
Drupal Javascript for developersDream Production AG
 
Drupal Development
Drupal DevelopmentDrupal Development
Drupal DevelopmentJeff Eaton
 
Staying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPStaying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPOscar Merida
 
Drupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp BratislavaDrupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp BratislavaGábor Hojtsy
 
Getting Started with DrupalGap
Getting Started with DrupalGapGetting Started with DrupalGap
Getting Started with DrupalGapAlex S
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Mike Schinkel
 

Similar to Advanced moduledevelopment d6_slideshare (20)

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
 
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
 
Learning the basics of the Drupal API
Learning the basics of the Drupal APILearning the basics of the Drupal API
Learning the basics of the Drupal API
 
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
 
Drupal Module Development - OSI Days 2010
Drupal Module Development - OSI Days 2010Drupal Module Development - OSI Days 2010
Drupal Module Development - OSI Days 2010
 
Drupal Module Development
Drupal Module DevelopmentDrupal Module Development
Drupal Module Development
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
Staying Sane with Drupal (A Develper's Survival Guide)
Staying Sane with Drupal (A Develper's Survival Guide)Staying Sane with Drupal (A Develper's Survival Guide)
Staying Sane with Drupal (A Develper's Survival Guide)
 
Fapi
FapiFapi
Fapi
 
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
 
Migrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindMigrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mind
 
Working with LoopBack Models
Working with LoopBack ModelsWorking with LoopBack Models
Working with LoopBack Models
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
 
Views Style Plugins
Views Style PluginsViews Style Plugins
Views Style Plugins
 
Drupal Javascript for developers
Drupal Javascript for developersDrupal Javascript for developers
Drupal Javascript for developers
 
Drupal Development
Drupal DevelopmentDrupal Development
Drupal Development
 
Staying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPStaying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHP
 
Drupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp BratislavaDrupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp Bratislava
 
Getting Started with DrupalGap
Getting Started with DrupalGapGetting Started with DrupalGap
Getting Started with DrupalGap
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
 

Recently uploaded

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 

Recently uploaded (20)

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 

Advanced moduledevelopment d6_slideshare

  • 1. Advanced Module Development (D6) Case study: UC_Etranzact Ubercart contrib module Kayode Odeyemi Technical Architect, Opevel DrupalCamp Lagos 2011
  • 2. Where to start from? There are various ways of starting a Drupal module; • Using Features module: Makes your Drupal module exportable and deployment easier. • Using Module Builder module: auto-generates a skeleton or "scaffolding" for a module
  • 3. Drupal Common Hooks • Hook_menu • Hook_init • Hook_help • Hook_nodeapi • Hook_theme • Hook_install • Hook_uninstall • Hook_form • Hook_form_alter • Hook_form_submit • Hook_form_validate
  • 4. Very useful Drupal APIs for everyday development • Module_invoke • Module_load_include • Drupal_write_record • Function_exists • Call_user_func_array • Db_table_exists • Db_query • Db_result • Db_object_fetch_array and db_object_fetch_object • Drupal_set_message or dsm if using devel module • Db_create_table • Update_sql • Views_get_views_result • Db_add_field • Db_drop_field • Drupal_get_schema • Element_children • Views_get_default_view
  • 5. Writing Drupal Hooks There are different ways of writing Drupal hooks. // Using module_implements inline within a non-hook function and using module_invoke foreach(module_implements(‘hook_name') as $module) { module_invoke($module, ‘hook_name', $args); } // Explicitly writing the hook as a function with module_implements alone function mymodule_hook($fees) { foreach (module_implements(‘hook_name') as $module) { $function = $module . '_hook_name'; $result = $function($fees); if (isset($result) && is_array($result)) { $return = array_merge($return, $result); } else if (isset($result)) { $return[] = $result; } } return $return; }
  • 6. drupal_http_request: Drupal's simple curl equivalent // curl $curl = curl_init(); $apiurl = variable_get('uc_etranzact_demo_mode', 1) ? UC_ETRANZACT_SERVICE_DEMO : UC_ETRANZACT_SERVICE; $apiurl = sprintf('%s?%s', $apiurl, $query); curl_setopt($curl, CURLOPT_URL, $apiurl); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); $return = curl_exec($curl); // drupal_http_request $result = drupal_http_request($uri, $header, $method, http_build_query($data, '', '&'));
  • 7. Test with SimpleTest • When your project is starting to get robust and clumsy, test with SimpleTest • Common SimpleTest APIs are: – drupalGetNodeByTitle($title) – drupalCreateNode($settings) – drupalCreateContentType($settings) - drupalCreateUser($permissions) – checkPermissions(array $permissions, $reset = FALSE): Check to make sure that the array of permissions are valid. – drupalLogin(stdClass $user): Log in a user with the internal browser.
  • 8. Test with SimpleTest – drupalLogout – assertNotEqual: Check to see if two values are not equal. – assertEqual: Check to see if two values are equal. – drupalPost: Execute a POST request on a Drupal page. – drupalGet: Retrieves a Drupal path or an absolute path. – assertTrue: Check to see if a value is not false (not an empty string, 0, NULL, or FALSE) – assertFalse: Check to see if a value is false (an empty string, 0, NULL, or FALSE). – assertNull: Check to see if a value is not NULL.
  • 9. Administer Drupal faster with Drupal • Drush is Drupal’s CLI language • Administer modules quickly with Drush • When working with multi-sites, Drush is your best friend • Drupal cheat sheet – Drush status – Drush dl <modulename> – Drush cc – Drush eval “<php code>” – Drush en <module name> – Drush dis <module name> – Drush up – Drush upc <module name> – … more on drupal.org
  • 10. Debugging Drupal • The devel module and theme developer modules are very handy tools for Debugging Drupal. • There’s also a firebug Drupal extension for debugging Drupal • Useful functions: – Dsm – Dpr – dvm
  • 11. Ubercart Payment Hooks and useful APIs • Hook_payment_method: define a custom payment method • Hook_order: define and process the order items • Hook_checkout_pane: define a custom pane for your order and style it • uc_order_status_data: Check the status of an order • uc_cart_empty(uc_cart_get_id()): Empty a cart • uc_order_save($order): save an order to the database • Hook_tapir_table_alter • Hook_cart_item: alter the items in cart • Hook_cart_pane: Override the cart pane • Hook_product_description: modify the descriptions of items in cart • Uc_cart_get_contents: get cart contents
  • 12. Understanding ubercart cart process • Add items to cart using uc_cart_add_items. • Checkout your order and implement hook_checkout_pane to customize the order items. • Review the order in different states namely: – New: only called if the order is new – Submit: Process the order such as integrating with a payment gateway like etranzact. – Save: Save your order in a database – Load: called immediately an order is successfully saved in the db
  • 13. How we build it: uc_etranzact module • Uc_etranzact module only requires a payment gateway implementation • Ubercart Hooks that got the job done: – Hook_payment_gateway – Hook_order – Callback functions to process the order to integrate with etranzact system
  • 14. Questions • Website - http://opevel.com • Twitter : @opevel @drupal @acquia • Opevel Services – Drupal custom development – Drupal site architecture – Custom Application Development on Google App Engine http://drupal.org/sandbox/charyorde/1310706 • Datasphir is hiring Drupal developers. – http://datasphir.com