SlideShare uma empresa Scribd logo
1 de 53
Baixar para ler offline
Module Development



      Ipsita Mishra
    Siva Kumar Epari


    http://melity.com
About Us

●Ipsita Mishra
✔4 years of Drupal experience

✔Tech lead

✔Webadmin & Core member of Drupal Hyderabad



●Siva Kumar Epari
✔2 years of Drupal experience

✔Drupal Developer

✔Webadmin & Core member of Drupal Hyderabad
Types of Modules



  Core Modules

 Contrib Modules

 Custom Module
Core Modules

These are the modules that ships with a Standard
Drupal Release. There are Core Optional and
Core Required modules.

For example:
Node
User
Block
System
Filter
Contrib Modules


Over 5800 (as of July 20, 2010) free community-
contributed modules, known as contrib modules,
are available to alter and extend Drupal's core
capabilities and add new features or customize
Drupal's behavior and appearance.
Popular Contrib Modules




These statistics are incomplete; only Drupal websites using
   the Update Status module are included in the data.
Custom Module


A Custom module is one which is local to your
Drupal Project. It's not yet contributed to the
contrib repository.
Custom Module(When to write)

You need to answer few questions before writing a
Custom Module
1. What do you want to achieve by this custom module?
2. Did you search the Contrib Repository to see if a
module is already available for that feature?
3. Have you enabled all possible Configurations of the
Core & Contrib module to check if they offer you the
feature you require?

If your answer is, “Yes, I have done enough research and
 am sure I have to write the code now”, then go ahead ....
Custom Module(Why to write)


I have 2 reasons to write a Custom module

1. I need a new feature which is not yet available in
Drupal, and probably can be contributed as a Contrib
Module.

2. I don't want to keep adding additional modules to my
site for small tweaks, which I can manage in only one
custom module for my website. Don't be too much
dependent on Contribs.
A simple module directory
        structure



                 modulename.info


    modulename


             modulename.module
new.info

                    ; $Id$

                name = Module name
                description = “Module description”
modulename.info core = Drupal version (e.g.: 5.x, 6.x)
                package = Package name



                    ; $Id$

                    name = Text Captcha
                    description = “Text Captcha”
     new.info       core = 6.x
                    package = Osidays
new.module
             <?php

             // $Id$

             function new_form_alter(&$form, &$form_state, $formid){
               if(substr($formid, -9) == 'node_form'){
                  $form['captcha'] = array(
                     '#type' => 'textfield',
                     '#title' => 'Captcha Question : What is 5 + 3?',
                  );
                  $form['#validate'][] = '_new_validate';
                  $form['#submit'][] = '_new_submit';
new.module     }
             }

             function _new_validate($form, &$form_state){
               if($form_state['values']['captcha'] != '8'){
                    form_set_error('captcha', 'Your Captcha answer is wrong!
             So you are not a human or you don't know counting :D');
               }
             }

             function _new_submit($form, &$form_state){
               drupal_set_message('You are a human!');
             }
Download examples module from
http://drupal.org/project/examples
http://drupal.org/project/examples
node_example module
hook_node_info()
hook_access()
hook_perm()
hook_perm() Output
http://localhost/drupal-6.19/admin/user/permissions
hook_form()
hook_form() Contd...
hook_validate()
hook_insert()
hook_schema()
hook_install() hook_uninstall()
hook_update()




Preventing SQL injection is easy; db_query provides a way to use
parametrized queries. Drupal's database functions replace the sprintf-like
placeholders with the properly escaped arguments in order of appearance:
%d - integers
%f - floats
%s - strings, enclose in single quotes
%b - binary data, do not enclose in single quotes
hook_nodeapi()
hook_delete()
hook_load()
hook_view()
hook_theme()
Theme function
Menu System
hook_menu()
Menu Item Types
"type": A bitmask of flags describing properties of the menu
item. Many shortcut bitmasks are provided as constants in
menu.inc:

  * MENU_NORMAL_ITEM: Normal menu items show up in
the menu tree and can be moved/hidden by the
administrator.
  * MENU_CALLBACK: Callbacks simply register a path so
that the correct function is fired when the URL is accessed.
  * MENU_SUGGESTED_ITEM: Modules may "suggest"
menu items that the administrator may enable.
  * MENU_LOCAL_TASK: Local tasks are rendered as tabs
by default.
  * MENU_DEFAULT_LOCAL_TASK: Every set of local tasks
should provide one "default" task, that links to the same
path as its parent when clicked.

If the "type" key is omitted, MENU_NORMAL_ITEM is
assumed.
hook_menu_alter()
Drupal Blocks
hook_block()
A Block represents some auxiliary content along
with the primary content of the page.
The output is themed
  comment.module
Parameters
hook_block($op = 'list', $delta = 0, $edit = array())
Operation: list
Operation: configure
Operation: save
Operation: view
Developer's Tools


●   Drush
●   Devel and Devel Themer
●   Coder
●   Admin Menu
DRUpal SHell

●   drush dl modulename/themename
●   drush en modulename/themename
●   drush dis modulename/themename
●   drush pm-uninstall modulename/themename
●   drush cc


Resource:
http://drupal.org/files/drush-cheat-sheet.pdf
Devel

● Devel: Helper functions for Drupal developers.
● Generate content: Accelerate development of

your site or module by quickly generating nodes,
comments, terms, users, and more.
● Node Access Summary: View the node access

entries for the node(s) that are shown on a page.
Devel Themer
Coder




This module helps in Code Review
A Sample Analysis by Coder
Resources
http://api.drupal.org




 IRC Channel
 #drupal
 #drupal-support
 #drupal-hyderabad
Thank You
@IpsitaMishra
@siva_epari

Mais conteúdo relacionado

Mais procurados

Drupal 8: Entities
Drupal 8: EntitiesDrupal 8: Entities
Drupal 8: Entitiesdrubb
 
Drupal.js: Best Practices for Managing Javascript in Drupal
Drupal.js: Best Practices for Managing Javascript in DrupalDrupal.js: Best Practices for Managing Javascript in Drupal
Drupal.js: Best Practices for Managing Javascript in DrupalBryan Braun
 
Система рендеринга в Magento
Система рендеринга в MagentoСистема рендеринга в Magento
Система рендеринга в MagentoMagecom Ukraine
 
Intro To jQuery In Drupal
Intro To jQuery In DrupalIntro To jQuery In Drupal
Intro To jQuery In DrupalMatthew Farina
 
JavaScript in Drupal 7: What developers need to know
JavaScript in Drupal 7: What developers need to knowJavaScript in Drupal 7: What developers need to know
JavaScript in Drupal 7: What developers need to knowkatbailey
 
Drupal 8: Theming
Drupal 8: ThemingDrupal 8: Theming
Drupal 8: Themingdrubb
 
Drupal Javascript for developers
Drupal Javascript for developersDrupal Javascript for developers
Drupal Javascript for developersDream Production AG
 
jQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 JavascriptjQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 JavascriptDarren Mothersele
 
AngulrJS Overview
AngulrJS OverviewAngulrJS Overview
AngulrJS OverviewEyal Vardi
 
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
 
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, GermanyLet's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, GermanyBalázs Tatár
 
Web2py tutorial to create db driven application.
Web2py tutorial to create db driven application.Web2py tutorial to create db driven application.
Web2py tutorial to create db driven application.fRui Apps
 
Writing Drupal 5 Module
Writing Drupal 5 ModuleWriting Drupal 5 Module
Writing Drupal 5 ModuleSammy Fung
 
Render API - Pavel Makhrinsky
Render API - Pavel MakhrinskyRender API - Pavel Makhrinsky
Render API - Pavel MakhrinskyDrupalCampDN
 
Django Admin: Widgetry & Witchery
Django Admin: Widgetry & WitcheryDjango Admin: Widgetry & Witchery
Django Admin: Widgetry & WitcheryPamela Fox
 

Mais procurados (20)

Drupal 8: Entities
Drupal 8: EntitiesDrupal 8: Entities
Drupal 8: Entities
 
Drupal.js: Best Practices for Managing Javascript in Drupal
Drupal.js: Best Practices for Managing Javascript in DrupalDrupal.js: Best Practices for Managing Javascript in Drupal
Drupal.js: Best Practices for Managing Javascript in Drupal
 
PHP MVC
PHP MVCPHP MVC
PHP MVC
 
Система рендеринга в Magento
Система рендеринга в MagentoСистема рендеринга в Magento
Система рендеринга в Magento
 
Intro To jQuery In Drupal
Intro To jQuery In DrupalIntro To jQuery In Drupal
Intro To jQuery In Drupal
 
JavaScript in Drupal 7: What developers need to know
JavaScript in Drupal 7: What developers need to knowJavaScript in Drupal 7: What developers need to know
JavaScript in Drupal 7: What developers need to know
 
Drupal 8: Theming
Drupal 8: ThemingDrupal 8: Theming
Drupal 8: Theming
 
Drupal Javascript for developers
Drupal Javascript for developersDrupal Javascript for developers
Drupal Javascript for developers
 
jQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 JavascriptjQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
 
AngulrJS Overview
AngulrJS OverviewAngulrJS Overview
AngulrJS Overview
 
Drupal 8 Hooks
Drupal 8 HooksDrupal 8 Hooks
Drupal 8 Hooks
 
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
 
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, GermanyLet's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
 
Presentation
PresentationPresentation
Presentation
 
Web2py tutorial to create db driven application.
Web2py tutorial to create db driven application.Web2py tutorial to create db driven application.
Web2py tutorial to create db driven application.
 
Drupal Render API
Drupal Render APIDrupal Render API
Drupal Render API
 
Writing Drupal 5 Module
Writing Drupal 5 ModuleWriting Drupal 5 Module
Writing Drupal 5 Module
 
Drupal 8 migrate!
Drupal 8 migrate!Drupal 8 migrate!
Drupal 8 migrate!
 
Render API - Pavel Makhrinsky
Render API - Pavel MakhrinskyRender API - Pavel Makhrinsky
Render API - Pavel Makhrinsky
 
Django Admin: Widgetry & Witchery
Django Admin: Widgetry & WitcheryDjango Admin: Widgetry & Witchery
Django Admin: Widgetry & Witchery
 

Semelhante a Drupal Module Development - OSI Days 2010

Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practicesmanugoel2003
 
Валентин Мацвейко та Владислав Мойсеєнко — 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
 
D7 theming what's new - London
D7 theming what's new - LondonD7 theming what's new - London
D7 theming what's new - LondonMarek Sotak
 
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
 
Debugging in drupal 8
Debugging in drupal 8Debugging in drupal 8
Debugging in drupal 8Allie Jones
 
Best Practices For Drupal Developers By Mir Nazim @ Drupal Camp India 2008
Best Practices For Drupal Developers By Mir Nazim @ Drupal Camp India 2008Best Practices For Drupal Developers By Mir Nazim @ Drupal Camp India 2008
Best Practices For Drupal Developers By Mir Nazim @ Drupal Camp India 2008Mir Nazim
 
What's new in the Drupal 7 API?
What's new in the Drupal 7 API?What's new in the Drupal 7 API?
What's new in the Drupal 7 API?Alexandru Badiu
 
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011camp_drupal_ua
 
ONE MORE TIME ABOUT CODE STANDARDS AND BEST PRACTICES
ONE MORE TIME ABOUT CODE STANDARDS AND BEST PRACTICESONE MORE TIME ABOUT CODE STANDARDS AND BEST PRACTICES
ONE MORE TIME ABOUT CODE STANDARDS AND BEST PRACTICESDrupalCamp Kyiv
 
Drupal vs WordPress
Drupal vs WordPressDrupal vs WordPress
Drupal vs WordPressWalter Ebert
 
Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes ramakesavan
 
Advanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshareAdvanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshareOpevel
 
Drupal tips 'n tricks
Drupal tips 'n tricksDrupal tips 'n tricks
Drupal tips 'n tricksJohn Tsevdos
 
Drupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp BratislavaDrupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp BratislavaGábor Hojtsy
 
#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)
#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)
#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)Konstantin Komelin
 
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
 

Semelhante a Drupal Module Development - OSI Days 2010 (20)

Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
Валентин Мацвейко та Владислав Мойсеєнко — 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
 
D7 theming what's new - London
D7 theming what's new - LondonD7 theming what's new - London
D7 theming what's new - London
 
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
 
Debugging in drupal 8
Debugging in drupal 8Debugging in drupal 8
Debugging in drupal 8
 
Best Practices For Drupal Developers By Mir Nazim @ Drupal Camp India 2008
Best Practices For Drupal Developers By Mir Nazim @ Drupal Camp India 2008Best Practices For Drupal Developers By Mir Nazim @ Drupal Camp India 2008
Best Practices For Drupal Developers By Mir Nazim @ Drupal Camp India 2008
 
What's new in the Drupal 7 API?
What's new in the Drupal 7 API?What's new in the Drupal 7 API?
What's new in the Drupal 7 API?
 
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
 
ONE MORE TIME ABOUT CODE STANDARDS AND BEST PRACTICES
ONE MORE TIME ABOUT CODE STANDARDS AND BEST PRACTICESONE MORE TIME ABOUT CODE STANDARDS AND BEST PRACTICES
ONE MORE TIME ABOUT CODE STANDARDS AND BEST PRACTICES
 
Drupal vs WordPress
Drupal vs WordPressDrupal vs WordPress
Drupal vs WordPress
 
Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes
 
Advanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshareAdvanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshare
 
Drupal Workshop: Introducción al Backend de Drupal
Drupal  Workshop: Introducción al Backend de DrupalDrupal  Workshop: Introducción al Backend de Drupal
Drupal Workshop: Introducción al Backend de Drupal
 
Drupal tips 'n tricks
Drupal tips 'n tricksDrupal tips 'n tricks
Drupal tips 'n tricks
 
Drupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp BratislavaDrupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp Bratislava
 
Drupal 7 database api
Drupal 7 database api Drupal 7 database api
Drupal 7 database api
 
#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)
#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)
#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)
 
#D8 cx: upgrade your modules to drupal 8
#D8 cx: upgrade your modules to drupal 8 #D8 cx: upgrade your modules to drupal 8
#D8 cx: upgrade your modules to drupal 8
 
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
 

Último

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Último (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

Drupal Module Development - OSI Days 2010

  • 1. Module Development Ipsita Mishra Siva Kumar Epari http://melity.com
  • 2. About Us ●Ipsita Mishra ✔4 years of Drupal experience ✔Tech lead ✔Webadmin & Core member of Drupal Hyderabad ●Siva Kumar Epari ✔2 years of Drupal experience ✔Drupal Developer ✔Webadmin & Core member of Drupal Hyderabad
  • 3. Types of Modules Core Modules Contrib Modules Custom Module
  • 4. Core Modules These are the modules that ships with a Standard Drupal Release. There are Core Optional and Core Required modules. For example: Node User Block System Filter
  • 5. Contrib Modules Over 5800 (as of July 20, 2010) free community- contributed modules, known as contrib modules, are available to alter and extend Drupal's core capabilities and add new features or customize Drupal's behavior and appearance.
  • 6. Popular Contrib Modules These statistics are incomplete; only Drupal websites using the Update Status module are included in the data.
  • 7. Custom Module A Custom module is one which is local to your Drupal Project. It's not yet contributed to the contrib repository.
  • 8. Custom Module(When to write) You need to answer few questions before writing a Custom Module 1. What do you want to achieve by this custom module? 2. Did you search the Contrib Repository to see if a module is already available for that feature? 3. Have you enabled all possible Configurations of the Core & Contrib module to check if they offer you the feature you require? If your answer is, “Yes, I have done enough research and am sure I have to write the code now”, then go ahead ....
  • 9. Custom Module(Why to write) I have 2 reasons to write a Custom module 1. I need a new feature which is not yet available in Drupal, and probably can be contributed as a Contrib Module. 2. I don't want to keep adding additional modules to my site for small tweaks, which I can manage in only one custom module for my website. Don't be too much dependent on Contribs.
  • 10. A simple module directory structure modulename.info modulename modulename.module
  • 11. new.info ; $Id$ name = Module name description = “Module description” modulename.info core = Drupal version (e.g.: 5.x, 6.x) package = Package name ; $Id$ name = Text Captcha description = “Text Captcha” new.info core = 6.x package = Osidays
  • 12. new.module <?php // $Id$ function new_form_alter(&$form, &$form_state, $formid){ if(substr($formid, -9) == 'node_form'){ $form['captcha'] = array( '#type' => 'textfield', '#title' => 'Captcha Question : What is 5 + 3?', ); $form['#validate'][] = '_new_validate'; $form['#submit'][] = '_new_submit'; new.module } } function _new_validate($form, &$form_state){ if($form_state['values']['captcha'] != '8'){ form_set_error('captcha', 'Your Captcha answer is wrong! So you are not a human or you don't know counting :D'); } } function _new_submit($form, &$form_state){ drupal_set_message('You are a human!'); }
  • 13. Download examples module from http://drupal.org/project/examples
  • 26. hook_update() Preventing SQL injection is easy; db_query provides a way to use parametrized queries. Drupal's database functions replace the sprintf-like placeholders with the properly escaped arguments in order of appearance: %d - integers %f - floats %s - strings, enclose in single quotes %b - binary data, do not enclose in single quotes
  • 35. Menu Item Types "type": A bitmask of flags describing properties of the menu item. Many shortcut bitmasks are provided as constants in menu.inc: * MENU_NORMAL_ITEM: Normal menu items show up in the menu tree and can be moved/hidden by the administrator. * MENU_CALLBACK: Callbacks simply register a path so that the correct function is fired when the URL is accessed. * MENU_SUGGESTED_ITEM: Modules may "suggest" menu items that the administrator may enable. * MENU_LOCAL_TASK: Local tasks are rendered as tabs by default. * MENU_DEFAULT_LOCAL_TASK: Every set of local tasks should provide one "default" task, that links to the same path as its parent when clicked. If the "type" key is omitted, MENU_NORMAL_ITEM is assumed.
  • 38. hook_block() A Block represents some auxiliary content along with the primary content of the page.
  • 39. The output is themed comment.module
  • 40. Parameters hook_block($op = 'list', $delta = 0, $edit = array())
  • 45. Developer's Tools ● Drush ● Devel and Devel Themer ● Coder ● Admin Menu
  • 46. DRUpal SHell ● drush dl modulename/themename ● drush en modulename/themename ● drush dis modulename/themename ● drush pm-uninstall modulename/themename ● drush cc Resource: http://drupal.org/files/drush-cheat-sheet.pdf
  • 47. Devel ● Devel: Helper functions for Drupal developers. ● Generate content: Accelerate development of your site or module by quickly generating nodes, comments, terms, users, and more. ● Node Access Summary: View the node access entries for the node(s) that are shown on a page.
  • 49. Coder This module helps in Code Review
  • 50. A Sample Analysis by Coder
  • 51. Resources http://api.drupal.org IRC Channel #drupal #drupal-support #drupal-hyderabad
  • 52.