Post on 07-Apr-2018
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 1/131
Angela “webchick” ByronDrupalcon Paris
September 2, 2009
Drupal 7
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 2/131
About Me• Started Drupal in 2005 as
Google Summer of Codestudent
• Obsessed with everythingDrupal (especially gettingnew people involved!)
• Using Drupal co-author,
Drupal Association boardmember, Drupal 7 co-maintainer
• Work at Lullabot doing
Drupal consulting andeducationTuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 3/131
Agenda
•Talk about how much Drupal 7 is going torock your face off.
• Talk about how YOU can help get Drupal 7out the door so we can start building even
more awesome sites!
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 4/131
What’s newin Drupal 7? ?
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 5/131
Changes forend-users
and clients
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 6/131
Usability improvements
http://drupalusability.org/
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 7/131
Password checker
Drupal 6
Drupal 7
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 8/131
Text format selectorDrupal 6
Drupal 7
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 9/131
Vertical tabsDrupal 6
Drupal 7
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 10/131
Permission screen
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 11/131
Default front pageDrupal 6
Drupal 7
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 12/131
Default/Minimal Profile
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 13/131
Default profile
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 14/131
D7UX
http://www.d7ux.org/Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 15/131
New Information
Architecture• New IA separates administrative tasks into
“contexts”:
• I’m dealing with content.
• I’m building out site structure.
• I’m changing my site’s appearance.• I’m managing the people who come to
my site.
• I’m configuring modules and settings.Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 16/131
Drupal 4.x IA
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 17/131
Drupal 4.x IA
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 18/131
Drupal 5 & 6 IA
(this list goes on forever...)Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 19/131
Drupal 5 & 6 IA
(this list goes on forever...)Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 20/131
Drupal 5 & 6 IA
(this list goes on forever...)Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 21/131
Drupal 5 & 6 IA
(this list goes on forever...)Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 22/131
Drupal 7 IA
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 23/131
Drupal 7 IA
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 24/131
Toolbar
New IA along the top
Shortcut bar for role-specific frequentlyaccessed items along the bottom
User account-relatedstuff easily accessible
needsyourhelp!
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 25/131
Admin Theme: “Seven”
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 26/131
Overlaysneedsyour
help!
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 27/131
Edit in placeneedsyourhelp!
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 28/131
Changes for
site builders
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 29/131
5.2
5.0
8.3
New Minimum
Re uirements
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 30/131
Timezone and Country
su ort
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 31/131
Users can cancel own
accounts
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 32/131
Mix and Match Public
and Private files
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 33/131
Internationalization
• New translation interface
•Search module supports language-awaresearches
• Fields are translatable
• Support for message contexts (msgctxt) tomake translation of short words like “View”much easier.
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 34/131
Native Image Handlingneedsyourhelp!
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 35/131
Native image handling
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 36/131
Security
• Prompted for e-mail notifications of securityupdates upon installation.
• PHP filter module now global “kill-switch” for“enter some PHP here” functionality.
•Cron.php requires key in URL to be run.
• New permission for running site updates.
• Limit login attempts, better flood control.
• Stronger, pluggable password hashing algorithm.Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 37/131
#smallcore
• Modules removed:
• Blog API
• Ping
• Throttle
• Upload
• Block module madeoptional
• Access rules removed
• Minimum # of words inBody removed
• User-selectable themesremoved
• Related terms, andtaxonomy +, URL
arguments removed
• Comment displayoptions removed
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 38/131
#largecore
• Contributed modulesmoved to core:
• Admin Role
• Feed API (some of it,anyway...)
• FileField
• Image
• ImageAPI
• ImageCache
• ImageField (soon...?)
• Install Profile API(some of it, anyway...)
• Poormanscron
• Token
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 39/131
#largecore
• Contributed modulesmoved to core:
• Admin Role
• Feed API (some of it,anyway...)
• FileField
• Image
• ImageAPI
• ImageCache
• ImageField (soon...?)
• Install Profile API(some of it, anyway...)
• Poormanscron
• Token
• Oh, yeah. And...
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 40/131
CCK!OMG!
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 41/131
Field Types in Core
• Boolean
• Decimal/Float/Integer
• File
• List
• Text/Textarea
• Taxonomy term
• Node Body
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 42/131
Fields be applied to
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 43/131
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 44/131
Fields be applied to
• Nodes (duh)
• Users (bye, Content Profile)
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 45/131
Fields be applied to
• Nodes (duh)
• Users (bye, Content Profile)• Comments (bye, Node Comment and
Comment Upload)
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 46/131
Fields be applied to
• Nodes (duh)
• Users (bye, Content Profile)• Comments (bye, Node Comment and
Comment Upload)
• Taxonomy terms (bye, Taxonomy Image)
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 47/131
Fields be applied to
• Nodes (duh)
•Users (bye, Content Profile)
• Comments (bye, Node Comment andComment Upload)
• Taxonomy terms (bye, Taxonomy Image)
• ...and that’s just in core! :)
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 48/131
Changes fordesigners and
front-enddevelopers
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 49/131
All butt-ugly, table-
based themes removedfrom core!
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 50/131
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 51/131
Re-vamped *.tpl.php
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 52/131
Re-vamped *.tpl.php
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 53/131
Re-vamped *.tpl.php
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 54/131
Re-vamped *.tpl.php
• Re-engineered XHTML structure to facilitate
CSS-only design.
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 55/131
Re-vamped *.tpl.php
• Re-engineered XHTML structure to facilitate
CSS-only design.• Standard, semantic class/ID names (.section,
#navigation, etc.)
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 56/131
Re-vamped *.tpl.php
• Re-engineered XHTML structure to facilitate
CSS-only design.• Standard, semantic class/ID names (.section,
#navigation, etc.)
• Improved consistency throughout.
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 57/131
Re-vamped *.tpl.php
• Re-engineered XHTML structure to facilitate
CSS-only design.• Standard, semantic class/ID names (.section,
#navigation, etc.)
• Improved consistency throughout.
• Enables designers to create beautiful, CSS-only themes without touching PHP.
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 58/131
And to show it off...
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 59/131
Stark: “Naked” Drupal
Tuesday, September 15, 2009
G l th i f
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 60/131
Granular theming of
content
• $content is a big string of XHTML.
• Fine-grained control over where *one* part
of content goes means being responsiblefor *all* parts of content. Securitynightmare.
• Comments are smooshed in here, too.
Drupal 6
Tuesday, September 15, 2009
Drupal 7
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 61/131
• $content is now an array of pageproperties that keeps track of what’s been
printed so far.
• Selectively hide parts until you’re ready toprint them where YOU want.
Drupal 7
...
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 62/131
Other awesomeness
• You can now preprocess theme functionsas well as template files
• Human-readable block IDs (block-user-online vs. block-user-3)
•Template-specific classes now compressed
into one $classes string, and also availableas $classes_array for raw values
• RDFa support
Tuesday, September 15, 2009
J S i t
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 63/131
JavaScript
im rovements• jQuery 1.3
• jQuery Forms 2.2
• jQuery UI 1.7
• drupal_add_library() for adding related JS/CSS files
• New CTools AJAX framework in core
• Can use jQuery alongside other JS
frameworks (Prototype, etc.)Tuesday, September 15, 2009
d l dd j / ()
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 64/131
drupal_add_js/css()
im rovements• Now pass in $options rather than 500
function arguments
• Uses actual weighting rather than awkward‘core’ vs. ‘module’ vs. ‘theme’ types.
•Add external files to the page.
• Alter CSS/JS array
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 65/131
Changes forcoders
01110111 01101001 0110110001101100 00100000 01100011 0110111101100100 01100101 00100000 0111000001101000 01110000 00100000 0110011001101111 01110010 00100000 0110011001101111 01101111 01100100
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 66/131
Warning:
Things are about toget... geeky.
Tuesday, September 15, 2009
m a n n /
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 67/131
h t t p : / / w w w . fl i c
k r . c o m / p h o t o s / s e b
a s t i a n_
b e r g m
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 68/131
SimpleTest
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 69/131
SimpleTest
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 70/131
SimpleTest
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 71/131
SimpleTest
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 72/131
SimpleTest
• Writing tests causes you to really think through a problem, and helps flesh outobscure bugs.
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 73/131
SimpleTest
• Writing tests causes you to really think through a problem, and helps flesh outobscure bugs.
• Know instantly if your changes break something; freedom to refactor wildly.
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 74/131
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 75/131
SimpleTest
• Writing tests causes you to really think through a problem, and helps flesh outobscure bugs.
• Know instantly if your changes break something; freedom to refactor wildly.
• Submit a test with your bug fix, it’ll stayfixed forever.
• Over 75% test coverage!
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 76/131
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 77/131
testing.drupal.org
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 78/131
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 79/131
testing.drupal.org
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 80/131
testing.drupal.org
• “Patch (code needs review)” and “Patch(reviewed & tested by community)”statuses can now be trusted.
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 81/131
testing.drupal.org
• “Patch (code needs review)” and “Patch(reviewed & tested by community)”statuses can now be trusted.
• Reviewers no longer getting carpal tunnelclicking through all the basic stuff.
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 82/131
testing.drupal.org
• “Patch (code needs review)” and “Patch(reviewed & tested by community)”statuses can now be trusted.
• Reviewers no longer getting carpal tunnelclicking through all the basic stuff.
• Running the full test suite takes a longtime; let a computer do it for you!
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 83/131
testing.drupal.org
• “Patch (code needs review)” and “Patch(reviewed & tested by community)”statuses can now be trusted.
• Reviewers no longer getting carpal tunnelclicking through all the basic stuff.
• Running the full test suite takes a longtime; let a computer do it for you!
• Notifies author within 24 hours if patch no
longer applies or breaks tests.Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 84/131
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 85/131
Database The next geNERATION
Tuesday, September 15, 2009
The who in the what
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 86/131
The who in the what
now?• Database abstraction layer utilizing PHP’s Data
Objects (PDO)
• Theoretical support for any database PHPsupports; mysql, sqlite, and pgsql drivers in D7.
• Support for master/slave replication, transactions,multi-insert queries, delayed inserts, and otherfeatures.
• Summary: Everything that ever sucked about ourDB abstraction layer is now fixed. ;)
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 87/131
Static Select Queries
$node = db_query('SELECT nid, title FROM {node} WHERE
type = :type AND nid = :nid', array(':type' => $type,
':nid' => $nid))->fetchObject();
Drupal 6:
Drupal 7:
$result = db_query("SELECT nid, title FROM {node} WHERE
type = '%s' AND nid = %d", array($type, $nid));$node = db_fetch_object($result);
Tuesday, September 15, 2009
Dynamic Select
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 88/131
Dynamic Select
QueriesDrupal 6:
$result = pager_query(db_rewrite_sql('SELECT n.nid FROM {node} n
WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC,
n.created DESC'), variable_get('default_nodes_main', 10));
Drupal 7:$select = db_select('node', 'n')
->fields('n', array('nid'))
->condition('promote', 1)->condition('status', 1)
->orderBy('sticky', 'DESC')
->orderBy('created', 'DESC')
->extend('PagerDefault')
->limit(variable_get('default_nodes_main', 10))
->addTag('node_access');Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 89/131
Other Queries
$nid = db_insert('node')
->fields(array('title', 'uid'))
->values(array(
'title' => 'Example',
'uid' => 1,
))
->execute();
$num_updated = db_update('node')
->fields(array(
'uid' => 5,
'status' => 1,))
->condition('created', REQUEST_TIME - 3600, '>=')
->execute();
Insert
Update
Delete$num_deleted = db_delete('node')
->condition('nid', 5)
->execute();
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 90/131
hook_query_alter()
function hook_db_rewrite_sql($query, $primary_table, $primary_field, $args) {
switch ($primary_field) { case 'nid':
$return = array();
if ($primary_table != 'n') { $return['join'] = "LEFT JOIN {node} n ON $primary_table.nid = n.nid";
}
$return['where'] = 'created >' . time() - 3600; return $return;
break;}
function hook_query_alter(&$query) {
if ($query->hasTag(‘node_access’)) {$query->condition(‘created’, time() - 3600, ‘>’);
}
}
Drupal 6:
Drupal 7:
Tuesday, September 15, 2009
F ld API
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 91/131
Field API
h t t p : / / w w
w . fl
i c k r . c o m / p h o t o
s / p i p e r /
Tuesday, September 15, 2009
Ab F ld API
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 92/131
About Field API
• No longer node-specific: can attach fieldsto users, potentially other objects.
• Declare any entity in Drupal as “fieldable”
• Swappable storage back-ends (currently,SQL but potentially web services, etc.)
• Supports translatable content.
needsyourhelp!
Tuesday, September 15, 2009
O
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 93/131
Bundles
name = Articletype = node
name = Usertype = user
Fields
name = subtitletype = text
name = phototype = image
FieldinstancesArticle subtitlewidget = text area
Article photowidget = file upload
User photowidget = file upload
Group of fieldsthat together make up
an entity
Base types
A field attachedto a particular bundle
Overview
Tuesday, September 15, 2009
O
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 94/131
Overview
Field:
How data is storedin database
Widget:How field is presentedon add/edit
Formatter:
How field ispresented on view
Tuesday, September 15, 2009
Fil St o
s / b u n n y /
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 95/131
File System h t t p : / / fl i c k r . c o m / p h o t
Tuesday, September 15, 2009
Fil API i
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 96/131
File API improvements
• Files are now first-class objects
• hook_file_load(), hook_file_save(),hook_file_move(), etc.
• Files are managed automatically; no need to
deal with {files} table yourself
• hook_file_url_alter() for CDN support
Tuesday, September 15, 2009
Stream Wrapper
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 97/131
Stream Wrapper
Support• Rather than referencing files by path, younow reference them by URI:schema://file/path/file.ext
• Allows you to change location of filesdirectory without a DB update.
• public://, private://, temp:// supported incore.
• Contrib can also create s3://, flickr://, etc.
Tuesday, September 15, 2009
I API
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 98/131
Image API
• Image toolkits now implemented asmodules, rather than .inc files that usersneed to copy over.
• Supports image manipulation effects: scale,crop, resize, rotate...
• Can combine these into “image styles” thatcan be applied to any image (user pictures,file uploads...)
Tuesday, September 15, 2009
r o m c c h s 0 8 /
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 99/131
Performance
h t t p : / / fl i c k r . c o m / p h
o t o s / t h a t g u y f r
Tuesday, September 15, 2009
R i
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 100/131
Registry
Tuesday, September 15, 2009
R i
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 101/131
Registry
Tuesday, September 15, 2009
R i
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 102/131
Registry
• Auto-parses and caches list of all functions,classes, and interfaces in all files
Tuesday, September 15, 2009
R i t
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 103/131
Registry
• Auto-parses and caches list of all functions,classes, and interfaces in all files
• Facilitates faster hook calls; only loopthrough modules that implement a hook
Tuesday, September 15, 2009
R i t
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 104/131
Registry
• Auto-parses and caches list of all functions,classes, and interfaces in all files
• Facilitates faster hook calls; only loopthrough modules that implement a hook
• Allows more fine-grained break-up of code(ex: all “info” functions inmodule.registry.inc)
Tuesday, September 15, 2009
R i t
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 105/131
Registry
• Auto-parses and caches list of all functions,classes, and interfaces in all files
• Facilitates faster hook calls; only loopthrough modules that implement a hook
• Allows more fine-grained break-up of code(ex: all “info” functions inmodule.registry.inc)
Tuesday, September 15, 2009
Cl i t
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 106/131
Class registry
• Auto-parses and caches list of all classesand interfaces in all files
• Allows you to do:
• ...from anywhere• Need to register all files in .info:
files[] = example.modulefiles[] = example.install
Tuesday, September 15, 2009
M lti l d! $ i
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 107/131
Multi-load! $queries--;
• node_load_multiple()
• file_load_multiple()
• taxonomy_term_load_multiple()
• taxonomy_vocabulary_load_multiple()
• user_load_multiple()
Tuesday, September 15, 2009
Faster, more scalable
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 108/131
,
Dru al• Proxy and reverse-proxy support: serveanon page requests entirely via proxy
• Tons of micro-optimizations caught byXDebug profiling
• Smarter look-ahead system for grabbing
path aliases
• InnoDB default storage system
• CDN support for files
needsyour
help!
Tuesday, September 15, 2009
H k d API o t o s / y a b a n j i /
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 109/131
Hooks and APIs
h t t p : / / fl i c k r . c o m / p h o
Tuesday, September 15, 2009
Ne H ks in D7
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 110/131
New Hooks in D7
• hook_modules_X(): installed, enabled,disabled, uninstalled
•hook_taxonomy_term_X(): load, insert,update, delete
• hook_taxonomy_vocabulary_X(): load,insert, update, delete
• hook_aggregator_X(): fetch, parse, process,remove
•hook_user_role_X(): delete, update, insert
Tuesday, September 15, 2009
No more $op
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 111/131
No more $op
• hook_nodeapi(), hook_user(),hook_block(), etc. are no longer “mega”
hooks:
• hook_node_load(), hook_node_update()
• hook_user_register(), hook_user_login()
• hook_block_list(), hook_block_view()
• hook_form_FORM_ID_alter()
works in6!
Tuesday, September 15, 2009
$page object
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 112/131
$page object
$page['left']['blocks']['user-navigation']['#block'] = (block
object);$page['content']['message']['#markup'] = 'Welcome to a big list of
nodes.';
$page['content']['nodes'] = (array of node objects keyed by node ID);
$page['content']['pager']['#markup'] = (HTML markup of pager);
$page['footer']['blocks']['system-powered-by']['#block'] = (block
object);
Tuesday, September 15, 2009
hook page alter()The most unholy hook of all...
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 113/131
hook_page_alter()
Tuesday, September 15, 2009
hook page alter()The most unholy hook of all...
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 114/131
hook_page_alter()
Tuesday, September 15, 2009
hook page alter()The most unholy hook of all...
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 115/131
hook_page_alter()
http://webchick.net/node/60Tuesday, September 15, 2009
Oh hai APIs!
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 116/131
Oh hai, APIs!
• Roles/Permissions API
• Filter/Format API
• Centralized static caching mechanism
• Locking framework
• Job queue
Tuesday, September 15, 2009
Node Access
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 117/131
Improvements• “administer nodes” and “bypass nodeaccess” two separate permissions
• Alter hook_node_grants andhook_node_access_records
• Node access applies to unpublished nodes
• hook_node_access() allows modules toinfluence access on nodes defined by othermodules
Tuesday, September 15, 2009
Install Profiles
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 118/131
Tuesday, September 15, 2009
Install Profiles
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 119/131
Drupal 6
Tuesday, September 15, 2009
Install Profiles
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 120/131
Drupal 6
default.profile
Tuesday, September 15, 2009
Install Profiles
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 121/131
Drupal 6 Drupal 7
default.profile
Tuesday, September 15, 2009
Install Profiles
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 122/131
Drupal 6
default.info
default.install
default.profile
Drupal 7
default.profile
Tuesday, September 15, 2009
Get the full list of
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 123/131
f
changes• CHANGELOG.txt
• http://drupal.org/update/modules/6/7
• http://drupal.org/update/theme/6/7
• http://drupal.org/project/coder
Tuesday, September 15, 2009
Let’s hear it for Drupal 7!
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 124/131
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 125/131
Nearly 500 contributors to Drupal 7 so far
Tuesday, September 15, 2009
Team Drupal 7(some of)
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 126/131
Team Drupal 7
Tuesday, September 15, 2009
Team Drupal 7(some of)
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 127/131
Team Drupal 7
Tuesday, September 15, 2009
HowYOU can help!
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 128/131
How YOU can help!
• Mark non-critical issuesas non-critical
• Write automated tests
• Fix bugs
• Hold local bug-fixsprints
• Help with critical freeze-extension issues
•Test and review patches
• Port modules andthemes to D7 to fleshout API issues
• Help with Codermodule
• Fix user-facing strings
• Update documentation
• Come to the sprint onSaturday! :)
Tuesday, September 15, 2009
#D7CX
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 129/131
#D7CX
http://cyrve.com/d7cx
Take the pledge.
Tuesday, September 15, 2009
Go find out more!
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 130/131
Go find out more!Sept 2 Sept 3
Sept 4
13:40 - 14:30: Explore the glory of Drupal 7'simproved render and theming systemsMoshe Weitzman
16:10 - 17:00:
Taxonomy Everywhere: D7 CoreOverhaul and the Expanding ContribUniverseBenjamin Melançon
17:15 - 18:00: Intro to the Field API for ModuleDevelopersBarry Jaspan
11:20 - 12:10: The state of RDF in Drupal 7Stephane Corlosquet
11:20 - 12:10: Image module in core: it's<strike>almost</strike> real!Nate Haug
11:20 - 12:10:
Introduction to testing withDrupal: SimpleTest
Jimmy Berry
Tuesday, September 15, 2009
8/3/2019 Drupal 7 by Angela “webchick” Byron
http://slidepdf.com/reader/full/drupal-7-by-angela-webchick-byron 131/131