SlideShare uma empresa Scribd logo
1 de 33
Baixar para ler offline
A Gentle Introduction


Addison Berry, Lullabot
DrupalCon, Washington, DC 2009
A lot of people get a bit overwhelmed by Drupal coding.
Sometimes that leads to running away or hacking.
Systems, Frameworks
               and APIs, Oh My!




API = set of functions that accomplish programming tasks - can be used “publicly”
Framework = basic app skeleton that solves common needs in a standardized way
CMS = features that help people build sites and manage content
Advantages: takes care of nasty, tedious stu; auth., security, etc. and its Open Source :)
Systems, Frameworks
               and APIs, Oh My!
                                        Content Management System
                                        built on the




API = set of functions that accomplish programming tasks - can be used “publicly”
Framework = basic app skeleton that solves common needs in a standardized way
CMS = features that help people build sites and manage content
Advantages: takes care of nasty, tedious stu; auth., security, etc. and its Open Source :)
Systems, Frameworks
               and APIs, Oh My!
                                        Content Management System
                                        built on the
                                        Framework,
                                        which uses the




API = set of functions that accomplish programming tasks - can be used “publicly”
Framework = basic app skeleton that solves common needs in a standardized way
CMS = features that help people build sites and manage content
Advantages: takes care of nasty, tedious stu; auth., security, etc. and its Open Source :)
Systems, Frameworks
               and APIs, Oh My!
                                        Content Management System
                                        built on the
                                        Framework,
                                        which uses the
                                        APIs
                                        (Application Programming
                                        Interface)

API = set of functions that accomplish programming tasks - can be used “publicly”
Framework = basic app skeleton that solves common needs in a standardized way
CMS = features that help people build sites and manage content
Advantages: takes care of nasty, tedious stu; auth., security, etc. and its Open Source :)
What is where?




CMS  framework  apis
Core modules and themes use the framework like everyone else.
Everyone should actually look at the files.
Includes folder holds the magic.
What is where?




CMS  framework  apis
Core modules and themes use the framework like everyone else.
Everyone should actually look at the files.
Includes folder holds the magic.
What is where?

                                                           base_path()
                                                           format_date()
                                                           l()
                                                           t()
                                                           url()




CMS  framework  apis
Core modules and themes use the framework like everyone else.
Everyone should actually look at the files.
Includes folder holds the magic.
Hooks

‣ Naming convention
  ‣ hook_* where hook is replaced
    by your module name
‣ Lets modules add their own stuff
  to Drupal’s workflow
A hook example

                                           Hey modules! I’m
                                           gonna display the
                                         permissions page, you
                                           have anything you
                                           want me to add?




Naming convention for functions that lets modules jump in to the Drupal workflow
hook_perm




Each module can respond by saying they have something.
If they don’t have anything, they just don’t use the hook.
blog_perm
                           I do!

                 blog




Each module can respond by saying they have something.
If they don’t have anything, they just don’t use the hook.
block_perm
                           I do!

                 blog




                            block

                                       me too

Each module can respond by saying they have something.
If they don’t have anything, they just don’t use the hook.
hook_perm
                           I do!

                 blog



                                                         blogapi
                            block                                  I don’t
                                       me too

Each module can respond by saying they have something.
If they don’t have anything, they just don’t use the hook.
Voila!




This is the display that gets made from hook_perm
The Train Analogy




•   The Node Train leaves the station with node/12 hitched
    It goes to the hook_nodeapi stop
    Attaches the taxonomy and comment cars
    Gets to the Theme depot
The Train Analogy




•   The Node Train leaves the station with node/12 hitched
    It goes to the hook_nodeapi stop
    Attaches the taxonomy and comment cars
    Gets to the Theme depot
The Train Analogy




•   The Node Train leaves the station with node/12 hitched
    It goes to the hook_nodeapi stop
    Attaches the taxonomy and comment cars
    Gets to the Theme depot
The Train Analogy




•   The Node Train leaves the station with node/12 hitched
    It goes to the hook_nodeapi stop
    Attaches the taxonomy and comment cars
    Gets to the Theme depot
Some major players
       Menu
       Form
       Database
       Theme
output: HTML, RSS
actions like: forwarding, login/logout
every internal link on a Drupal site is controlled by the menu system
Menu
                        ๏menu.inc != menu.module
                        ๏maps URLs to functions
                        ๏functions can display output
                           and initiate actions




output: HTML, RSS
actions like: forwarding, login/logout
every internal link on a Drupal site is controlled by the menu system
give it an array and it will give you the form
not just for devs. themers can control form output
give it an array and it will give you the form
not just for devs. themers can control form output
FAPI

                      • form.inc
                      • handles the form, validation
                         and submission




give it an array and it will give you the form
not just for devs. themers can control form output
dbs are not standardized for creation (schema)
built in security
Database

                         • database.inc (and
                            database*.inc)

                         • schema creation
                         • abstracted to work with
                            multiple databases


dbs are not standardized for creation (schema)
built in security
output is put through the theme system
many core theme elements are found in tpl files in the modules
Theme layer
             ✦theme.inc
             ✦system module has default tpls
                    block, box, page
                ✦

             ✦ other tpls are in the module folder



output is put through the theme system
many core theme elements are found in tpl files in the modules
Theme’s rule
they get a last crack at all output so the themer can change whatever they need
a function named mytheme_function_name will trump core and modules
✴Module output uses theme()
                       ✴Order of priority:
                          ✴ theme_function_name()
                          ✴ phptemplate_function_name()
                          ✴ mytheme_function_name()


Theme’s rule
they get a last crack at all output so the themer can change whatever they need
a function named mytheme_function_name will trump core and modules
Resources
Developer/Theme handbooks
Drupal source/api.drupal.org
Dev/Theme mailing lists (drupal.com/mailing-lists)
IRC: #drupal (#drupal-dev) #drupal-themes
Issue queues
Paper books: http://drupal.org/books

Mais conteúdo relacionado

Mais procurados (8)

Javascript Best Practices
Javascript Best PracticesJavascript Best Practices
Javascript Best Practices
 
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.frameworkHanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
 
Drupal Flyover, CMS Expo
Drupal Flyover, CMS ExpoDrupal Flyover, CMS Expo
Drupal Flyover, CMS Expo
 
<Head> Presentation: Plugging Into Wordpress
<Head> Presentation: Plugging Into Wordpress<Head> Presentation: Plugging Into Wordpress
<Head> Presentation: Plugging Into Wordpress
 
Ant User Guide
Ant User GuideAnt User Guide
Ant User Guide
 
Jsf2 composite-components
Jsf2 composite-componentsJsf2 composite-components
Jsf2 composite-components
 
Ajax Tags Advanced
Ajax Tags AdvancedAjax Tags Advanced
Ajax Tags Advanced
 
Zotonic presentation Erlang Camp Boston, august 2011
Zotonic presentation Erlang Camp Boston, august 2011Zotonic presentation Erlang Camp Boston, august 2011
Zotonic presentation Erlang Camp Boston, august 2011
 

Semelhante a Gentle Intro to Drupal Code

Drupal module development
Drupal module developmentDrupal module development
Drupal module development
Rachit Gupta
 
How to? Drupal developer toolkit. Dennis Povshedny.
How to? Drupal developer toolkit. Dennis Povshedny.How to? Drupal developer toolkit. Dennis Povshedny.
How to? Drupal developer toolkit. Dennis Povshedny.
DrupalCampDN
 
Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To Drupal
Lauren Roth
 

Semelhante a Gentle Intro to Drupal Code (20)

Drupal - Introduction to Drupal Creating Modules
Drupal - Introduction to Drupal Creating ModulesDrupal - Introduction to Drupal Creating Modules
Drupal - Introduction to Drupal Creating Modules
 
Drupal
DrupalDrupal
Drupal
 
Architecture of Drupal - Drupal Camp
Architecture of Drupal - Drupal CampArchitecture of Drupal - Drupal Camp
Architecture of Drupal - Drupal Camp
 
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
 
Rapid site production with Drupal
Rapid site production with DrupalRapid site production with Drupal
Rapid site production with Drupal
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module development
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
Hacking core
Hacking coreHacking core
Hacking core
 
Aurelia intro
Aurelia introAurelia intro
Aurelia intro
 
Patterns Drupal Camp Pune09
Patterns Drupal Camp Pune09Patterns Drupal Camp Pune09
Patterns Drupal Camp Pune09
 
SynapseIndia drupal presentation on drupal best practices
SynapseIndia drupal  presentation on drupal best practicesSynapseIndia drupal  presentation on drupal best practices
SynapseIndia drupal presentation on drupal best practices
 
Entity cache
Entity cacheEntity cache
Entity cache
 
How to? Drupal developer toolkit. Dennis Povshedny.
How to? Drupal developer toolkit. Dennis Povshedny.How to? Drupal developer toolkit. Dennis Povshedny.
How to? Drupal developer toolkit. Dennis Povshedny.
 
Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To Drupal
 
The Drupal 7 Worst Practices Catalogue
The Drupal 7 Worst Practices CatalogueThe Drupal 7 Worst Practices Catalogue
The Drupal 7 Worst Practices Catalogue
 
Maven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable ResultsMaven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable Results
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API Changes
 
Top 20 mistakes you will make on your 1st Drupal project
Top 20 mistakes you will make on your 1st Drupal projectTop 20 mistakes you will make on your 1st Drupal project
Top 20 mistakes you will make on your 1st Drupal project
 
Introduction And Basics of Modules in Drupal 7
Introduction And Basics of Modules in Drupal 7 Introduction And Basics of Modules in Drupal 7
Introduction And Basics of Modules in Drupal 7
 
Drupal development
Drupal development Drupal development
Drupal development
 

Mais de Addison Berry (6)

Gentle Intro to Drupal Code
Gentle Intro to Drupal CodeGentle Intro to Drupal Code
Gentle Intro to Drupal Code
 
The Drupal Movement: where do you fit in?
The Drupal Movement: where do you fit in?The Drupal Movement: where do you fit in?
The Drupal Movement: where do you fit in?
 
Open Source Docs don't have to suck
Open Source Docs don't have to suckOpen Source Docs don't have to suck
Open Source Docs don't have to suck
 
Drupal Documentation (Argentina)
Drupal Documentation (Argentina)Drupal Documentation (Argentina)
Drupal Documentation (Argentina)
 
Documentation is Hot
Documentation is HotDocumentation is Hot
Documentation is Hot
 
It's The People Stupid!
It's The People Stupid!It's The People Stupid!
It's The People Stupid!
 

Último

Último (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

Gentle Intro to Drupal Code

  • 1. A Gentle Introduction Addison Berry, Lullabot DrupalCon, Washington, DC 2009
  • 2. A lot of people get a bit overwhelmed by Drupal coding. Sometimes that leads to running away or hacking.
  • 3. Systems, Frameworks and APIs, Oh My! API = set of functions that accomplish programming tasks - can be used “publicly” Framework = basic app skeleton that solves common needs in a standardized way CMS = features that help people build sites and manage content Advantages: takes care of nasty, tedious stu; auth., security, etc. and its Open Source :)
  • 4. Systems, Frameworks and APIs, Oh My! Content Management System built on the API = set of functions that accomplish programming tasks - can be used “publicly” Framework = basic app skeleton that solves common needs in a standardized way CMS = features that help people build sites and manage content Advantages: takes care of nasty, tedious stu; auth., security, etc. and its Open Source :)
  • 5. Systems, Frameworks and APIs, Oh My! Content Management System built on the Framework, which uses the API = set of functions that accomplish programming tasks - can be used “publicly” Framework = basic app skeleton that solves common needs in a standardized way CMS = features that help people build sites and manage content Advantages: takes care of nasty, tedious stu; auth., security, etc. and its Open Source :)
  • 6. Systems, Frameworks and APIs, Oh My! Content Management System built on the Framework, which uses the APIs (Application Programming Interface) API = set of functions that accomplish programming tasks - can be used “publicly” Framework = basic app skeleton that solves common needs in a standardized way CMS = features that help people build sites and manage content Advantages: takes care of nasty, tedious stu; auth., security, etc. and its Open Source :)
  • 7. What is where? CMS framework apis Core modules and themes use the framework like everyone else. Everyone should actually look at the files. Includes folder holds the magic.
  • 8. What is where? CMS framework apis Core modules and themes use the framework like everyone else. Everyone should actually look at the files. Includes folder holds the magic.
  • 9. What is where? base_path() format_date() l() t() url() CMS framework apis Core modules and themes use the framework like everyone else. Everyone should actually look at the files. Includes folder holds the magic.
  • 10. Hooks ‣ Naming convention ‣ hook_* where hook is replaced by your module name ‣ Lets modules add their own stuff to Drupal’s workflow
  • 11. A hook example Hey modules! I’m gonna display the permissions page, you have anything you want me to add? Naming convention for functions that lets modules jump in to the Drupal workflow
  • 12. hook_perm Each module can respond by saying they have something. If they don’t have anything, they just don’t use the hook.
  • 13. blog_perm I do! blog Each module can respond by saying they have something. If they don’t have anything, they just don’t use the hook.
  • 14. block_perm I do! blog block me too Each module can respond by saying they have something. If they don’t have anything, they just don’t use the hook.
  • 15. hook_perm I do! blog blogapi block I don’t me too Each module can respond by saying they have something. If they don’t have anything, they just don’t use the hook.
  • 16. Voila! This is the display that gets made from hook_perm
  • 17. The Train Analogy • The Node Train leaves the station with node/12 hitched It goes to the hook_nodeapi stop Attaches the taxonomy and comment cars Gets to the Theme depot
  • 18. The Train Analogy • The Node Train leaves the station with node/12 hitched It goes to the hook_nodeapi stop Attaches the taxonomy and comment cars Gets to the Theme depot
  • 19. The Train Analogy • The Node Train leaves the station with node/12 hitched It goes to the hook_nodeapi stop Attaches the taxonomy and comment cars Gets to the Theme depot
  • 20. The Train Analogy • The Node Train leaves the station with node/12 hitched It goes to the hook_nodeapi stop Attaches the taxonomy and comment cars Gets to the Theme depot
  • 21. Some major players Menu Form Database Theme
  • 22. output: HTML, RSS actions like: forwarding, login/logout every internal link on a Drupal site is controlled by the menu system
  • 23. Menu ๏menu.inc != menu.module ๏maps URLs to functions ๏functions can display output and initiate actions output: HTML, RSS actions like: forwarding, login/logout every internal link on a Drupal site is controlled by the menu system
  • 24. give it an array and it will give you the form not just for devs. themers can control form output
  • 25. give it an array and it will give you the form not just for devs. themers can control form output
  • 26. FAPI • form.inc • handles the form, validation and submission give it an array and it will give you the form not just for devs. themers can control form output
  • 27. dbs are not standardized for creation (schema) built in security
  • 28. Database • database.inc (and database*.inc) • schema creation • abstracted to work with multiple databases dbs are not standardized for creation (schema) built in security
  • 29. output is put through the theme system many core theme elements are found in tpl files in the modules
  • 30. Theme layer ✦theme.inc ✦system module has default tpls block, box, page ✦ ✦ other tpls are in the module folder output is put through the theme system many core theme elements are found in tpl files in the modules
  • 31. Theme’s rule they get a last crack at all output so the themer can change whatever they need a function named mytheme_function_name will trump core and modules
  • 32. ✴Module output uses theme() ✴Order of priority: ✴ theme_function_name() ✴ phptemplate_function_name() ✴ mytheme_function_name() Theme’s rule they get a last crack at all output so the themer can change whatever they need a function named mytheme_function_name will trump core and modules
  • 33. Resources Developer/Theme handbooks Drupal source/api.drupal.org Dev/Theme mailing lists (drupal.com/mailing-lists) IRC: #drupal (#drupal-dev) #drupal-themes Issue queues Paper books: http://drupal.org/books