Your SlideShare is downloading. ×
0
Drupal:
Under the Hood
What is Drupal?

1. Content Management System
2. Content Management Framework
3. Community
Content Management
      System
file
                  uploads
               revisions menus
          security user profiles
   blocks performance modul...
1200+ Contributed
    Modules
Community
Doubles in size each
                     release




source: http://acko.net/blog/drupal-org-explosion-and-trends   sourc...
Statistics
• 840+ code contributors
• 160+ local user groups
• 430+ attendees at Drupalcon Barcelona
• 200,000+ users on d...
Content Management
    Framework
xml-rpc
                file api jquery
       database abstraction layer form
     api file api session management node
 ...
What’s under the hood?
Core
•   Lightweight framework
                            Drupal Core

•   Library of common         Content        User
...
Modules
                                  Drupal Core
                                    Content        User
            ...
INSTALL.txt    index.php    themes




 install.php   update.php   modules




    sites      xmlrpc.php   includes
drupal_bootstrap()
•   DRUPAL_BOOTSTRAP_CONFIGURATION

•   DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE

•   DRUPAL_BOOTSTRAP_DATABAS...
menu system
Yes
     Is site                         Return
    offline?                     MENU_SITE_OFFLINE


         No


Get menu...
Hooks
Hooks are PHP functions
with Drupal-specific names
How Drupal Finds Hooks

/**
  * Determine whether a module implements a hook.
  *
  * @param $module
  *    The name of th...
Naming Hooks

Module    Hook   Function name
pants     user   pants_user()

pants     menu   pants_menu()
pants     perm  ...
Hook Overview

                               hook_user()




  comment_user()    locale_user()        node_user()   mymod...
FormAPI
FormAPI

• Form elements are PHP arrays so you can
  programmatically manipulate any form
• Chain validator and submitter ...
Form Example
$form['user_name'] = array(
   '#title' => t('Your Name'),
   '#type' => 'textfield',
   '#description' => t(...
Security

• Verifies that $_POST values have
  corresponding $form elements
• Form rendering sanitized for potential XSS
• ...
hook_form_alter
drupal_execute()
Theme System
Theme System
PHPTemplate Files

   •   page.tpl.php
   •   node.tpl.php
   •   block.tpl.php
   •   comment.tpl.php
   •   box.tpl.php
theme('breadcrumb')




                      theme-name_breadcrumb()




                      theme-engine_breadcrumb()
...
theme('page')




                   garland_page()




                 phptemplate_page()




                   theme_p...
Creating New Template Files
template.php
function mytheme_breadcrumb($breadcrumb) {
  if (!empty($breadcrumb)) {
    retur...
ultimate control
http://greenpeace.co.uk/
http://theonion.com/
http://musicbox.sonybmg.com/
http://43folders.com/
http://lifetimetv.com/
http://flex.org/showcase
http://help.yahoo.com/
http://ubuntu.com/
Thanks... Questions?

James Walker
http://walkah.net/

Lullabot
james@lullabot.com
Upcoming SlideShare
Loading in...5
×

2007 Fsoss Drupal Under The Hood

12,305

Published on

Brief look at Drupal's internal features - given at http://fsoss.senecac.on.ca/2007/

Published in: Business, Technology
1 Comment
4 Likes
Statistics
Notes
  • If you want to check out a cool Drupal based site visit OracleLink.com - The Oracle Community Network

    http://www.oraclelink.com
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
12,305
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
132
Comments
1
Likes
4
Embeds 0
No embeds

No notes for slide

Transcript of "2007 Fsoss Drupal Under The Hood"

  1. 1. Drupal: Under the Hood
  2. 2. What is Drupal? 1. Content Management System 2. Content Management Framework 3. Community
  3. 3. Content Management System
  4. 4. file uploads revisions menus security user profiles blocks performance modules search engine-friendly urls user manage- ment administration panels localization error reporting rss taxonomy blogging comments forums multi-site installations event logging community authoring ajax search free tagging feed aggregation contact form help system roles and per- missions statistics tracking polls
  5. 5. 1200+ Contributed Modules
  6. 6. Community
  7. 7. Doubles in size each release source: http://acko.net/blog/drupal-org-explosion-and-trends source: http://buytaert.net/drupal-site-statistics
  8. 8. Statistics • 840+ code contributors • 160+ local user groups • 430+ attendees at Drupalcon Barcelona • 200,000+ users on drupal.org • 3 million+ lines of code (core+contrib) • 52 SoC mentors for 20 students • 100,000+ downloads/month
  9. 9. Content Management Framework
  10. 10. xml-rpc file api jquery database abstraction layer form api file api session management node system url routing theme system string handling filter system content versioning installation profiles access control trans- latable output user system caching date/time handling unicode support mail handling image manipulation installation system hook system menu system module system user authentication themable output
  11. 11. What’s under the hood?
  12. 12. Core • Lightweight framework Drupal Core • Library of common Content User Forms API Management Management functions Install Theming • Localization Allows Drupal to Profiles Layer bootstrap and serve a request Library of Common Functions • What you get when you download Drupal
  13. 13. Modules Drupal Core Content User Forms API • Management Management How Drupal is extended Install Theming Localization • Profiles Layer Lean and mean and versatile • Library of Common Functions Inversion of control design pattern Modules • Actions/ Content Drupal exposes hooks Ecommerce Workflows Creation Kit for modules Organic Views Groups Custom Module
  14. 14. INSTALL.txt index.php themes install.php update.php modules sites xmlrpc.php includes
  15. 15. drupal_bootstrap() • DRUPAL_BOOTSTRAP_CONFIGURATION • DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE • DRUPAL_BOOTSTRAP_DATABASE • DRUPAL_BOOTSTRAP_ACCESS • DRUPAL_BOOTSTRAP_SESSION • DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE • DRUPAL_BOOTSTRAP_PATH • DRUPAL_BOOTSTRAP_FULL
  16. 16. menu system
  17. 17. Yes Is site Return offline? MENU_SITE_OFFLINE No Get menu array Is callback No Parse $path from Trim last '/' from defined for $_GET['q'] $path $path? No Does callback Return function exist? MENU_NOT_FOUND User allowed No Return to access this MENU_ACCESS_DENIED item? Marshall parameters from URL and item's Call callback callback arguments
  18. 18. Hooks
  19. 19. Hooks are PHP functions with Drupal-specific names
  20. 20. How Drupal Finds Hooks /** * Determine whether a module implements a hook. * * @param $module * The name of the module (without the .module extension). * @param $hook * The name of the hook (e.g. quot;helpquot; or quot;menuquot;). */ function module_hook($module, $hook) { return function_exists($module .'_'. $hook); }
  21. 21. Naming Hooks Module Hook Function name pants user pants_user() pants menu pants_menu() pants perm pants_perm()
  22. 22. Hook Overview hook_user() comment_user() locale_user() node_user() mymodule_user() comment.module locale.module node.module mymodule.module
  23. 23. FormAPI
  24. 24. FormAPI • Form elements are PHP arrays so you can programmatically manipulate any form • Chain validator and submitter routines • Theme overrides - down to the element! • Built-in security
  25. 25. Form Example $form['user_name'] = array( '#title' => t('Your Name'), '#type' => 'textfield', '#description' => t('Please enter your name.'), ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit') );
  26. 26. Security • Verifies that $_POST values have corresponding $form elements • Form rendering sanitized for potential XSS • $form[‘token’] used to prevent CSRF
  27. 27. hook_form_alter
  28. 28. drupal_execute()
  29. 29. Theme System
  30. 30. Theme System
  31. 31. PHPTemplate Files • page.tpl.php • node.tpl.php • block.tpl.php • comment.tpl.php • box.tpl.php
  32. 32. theme('breadcrumb') theme-name_breadcrumb() theme-engine_breadcrumb() theme_breadcrumb() The first function found gets called.
  33. 33. theme('page') garland_page() phptemplate_page() theme_page() The first function found gets called.
  34. 34. Creating New Template Files template.php function mytheme_breadcrumb($breadcrumb) { if (!empty($breadcrumb)) { return '<span class=quot;breadcrumbquot;>'. implode(' * ', $breadcrumb) .'</span>'; } } new template.php function mytheme_breadcrumb($breadcrumb) { if (!empty($breadcrumb)) { $variables = array('breadcrumb' => implode(' * ', $breadcrumb)); return _phptemplate_callback('breadcrumb', $variables); } } breadcrumb.tpl.php <span class=quot;breadcrumbquot;><?php print $breadcrumb ?></span>
  35. 35. ultimate control
  36. 36. http://greenpeace.co.uk/
  37. 37. http://theonion.com/
  38. 38. http://musicbox.sonybmg.com/
  39. 39. http://43folders.com/
  40. 40. http://lifetimetv.com/
  41. 41. http://flex.org/showcase
  42. 42. http://help.yahoo.com/
  43. 43. http://ubuntu.com/
  44. 44. Thanks... Questions? James Walker http://walkah.net/ Lullabot james@lullabot.com
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×