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
 
Migrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindMigrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindValentine Matsveiko
 
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...LEDC 2016
 
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
 
Migrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindMigrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mind
 
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
 
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

Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 

Recently uploaded (20)

Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 

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