2. Not a drag and drop app builder
Hook system
not obvious
Reminiscent of old word processor print drivers
Best suited to web apps
Output need not HTML
XML, RSS, services
New in 7
render elements universal - used to be in form
Render elements are new to Drupal 7's theme layer. They've existed since Drupal 4.7 as part of the Form API, but they've now been injected into the heart of the theme system. A Render
element is a complex data structure passed as a single parameter to theme(), as one of its variables. Render elements are fundamentally nested arrays that can include:
The data to be rendered Other render elements which are considered "children" of the element An array of structures such as CSS and JavaScript files, that should be attached to the page
when it is rendered A list of theme hooks that can be used to theme the data A list of callback functions to run on the element before and after it is themed
Climbing the hook tree
You can see a good implementation of this in views
In Drupal 7, there are 184 theme hooks that you could use in your own code. Many of those theme hooks are specific to a core module's usage, like theming an administration form, but it's
still useful to go through the entire list to find hooks you could reuse. To make it even easier, we've included a list of the most commonly reused theme hooks:
Credo: Sacrifice the API, preserve data. Means that API chances between version can be apocalyptic.
Data values in forms - move data in array - form_state
Persistent data in db
Tokens in core
Like several things moved into core, admin/interface remains in contrib - see field API
Drupal 7 introduces major changes to the way Drupal handles content. In earlier versions, nearly all content was considered a "node". By making content a standard object with a common
API, any module could add data to and manipulate that object to create complex data models and workflows.
That worked extremely well, with the exception that Drupal had several other types of objects, such as users or comments, that were not really "content" per se but could still have benefited
from the same rich API. For Drupal 7, therefore, most of those separate object types were merged into a single super-system known as "entities". Nodes, users, comments, and several
other types of data objects are now particular instances of the generic Entity data object concept. That allows all types of data to have the same, or at least very similar, API and workflow,
avoiding duplicate code and reducing the number of moving parts developers need to keep track of. Most importantly, it allows us to attach Fields, discrete structured pieces of information,
to any type of entity rather than just to nodes.
Bundles - entity subtypes
Schema API
3. What is Drupal?
• OOTB blog/website/CMS
• A set of APIs that let you turn it into almost
anything
4. What is Drupal?
• OOTB blog/website/CMS
• Okay, it’s still harder to get going than Wordpress, but it is much
improved in that regard in Drupal 7
• We don’t care
• A set of APIs that let you turn it into almost
anything
• This is the interesting part
5. Some Assumptions
• You have heard of Drupal
• You know that it is a popular CMS in the
library community
• You might know that it is easy to extend
• You might have heard some of the reasons,
like the hook system
7. 7
• Why so long?
• Better alignment of contributed and core funcionality
• Stuff we have been waiting for since Drupal 5 and
Drupal 4.7
• #D7CX pledge:
• My module will be ready on the day Drupal 7 is
released
8. The Drupal Credo
Sac!fice " API, preserve " data
• Means that user data is gold. Developer effort
is expendable.
• API changes between versions can be
apocalyptic.
9. (Short) Tale of Two
Drupals
• Modules
• Theme
• Theme hooks
• Templates
10. Hook
• Reminiscent of ancient word processor print driver system
• Intercepted processes to build print stream
• Matched two APIs
• What the program wanted to send
• What the printer expected to see
• Economics - word processor companies wanted others to do their work for
them
• Flash forward
• Open source software
• A very simple system that allows developers to insert or modify functionality
almost anywhere. Without talking to each other.
13. What’s in the Box
Files that say stuff:
CHANGELOG.txt
COPYRIGHT.txt
INSTALL.mysql.txt
INSTALL.pgsql.txt
INSTALL.sqlite.txt
INSTALL.txt
LICENSE.txt
MAINTAINERS.txt
README.txt
UPGRADE.txt
14. What’s in the Box
Files that do stuff:
authorize.php
cron.php
index.php
install.php
robots.txt
update.php
web.config
xmlrpc.php
15. What’s in the Box
Directories:
includes
misc
profiles
scripts
modules
themes
sites
all
modules
themes
libraries
default
16. Modules
• Core module
• Contrib modules
• Learn to love associative arrays. Passing data
in strings is dead(ish)
• By using core hooks, modules achieve instant
interoperabity
17. help.info
; $Id: help.info,v 1.9 2010/12/20 19:59:42 webchick Exp $
name = Help
description = Manages the display of online help.
package = Core
version = VERSION
core = 7.x
files[] = help.test
; Information added by drupal.org packaging script on 2011-01-05
version = "7.0"
project = "drupal"
datestamp = "1294208756"
20. help.module -3
/**
* Implements hook_help().
*/
function help_help($path, $arg) {
switch ($path) {
case 'admin/help':
$output = '<p>' . t('Follow these steps to set up and start using your website:') . '</p>';
$output .= '<ol>';
$output .= '<li>' . t('<strong>Configure your website</strong> Once logged in, visit the <a href="@admin">administration section</a>, where you
can <a href="@config">customize and configure</a> all aspects of your website.', array('@admin' => url('admin'), '@config' => url('admin/config'))) .
'</li>';
$output .= '</ol>';
$output .= '<p>' . t('For more information, refer to the specific topics listed in the next section or to the <a href="@handbook">online Drupal
handbooks</a>. You may also post at the <a href="@forum">Drupal forum</a> or view the wide range of <a href="@support">other support
options</a> available.', array('@help' => url('admin/help'), '@handbook' => 'http://drupal.org/handbooks', '@forum' => 'http://drupal.org/forum',
'@support' => 'http://drupal.org/support')) . '</p>';
---snip---
return $output;
case 'admin/help#help':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
---snip---
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Providing a help reference') . '</dt>';
---snip---
$output .= '<dd>' . t('The Help module displays context-sensitive advice and explanations on various pages.') . '</dd>';
$output .= '</dl>';
return $output;
}
}
21. help.test
<?php
// $Id: help.test,v 1.22 2010/11/27 20:25:44 dries Exp $
class HelpTestCase extends DrupalWebTestCase {
protected $big_user;
protected $any_user;
public static function getInfo() {
return array(
'name' => 'Help functionality',
'description' => 'Verify help display and user access to help based on permissions.',
'group' => 'Help',
);
}
/**
* Enable modules and create users with specific permissions.
*/
function setUp() {
parent::setUp('blog', 'poll');
$this->getModuleList();
// Create users.
$this->big_user = $this->drupalCreateUser(array('access administration pages', 'view the administration theme',
'administer permissions'));
$this->any_user = $this->drupalCreateUser(array());
}
}
22. Drupal APIs. Yum.
• core modules call core hooks
• Drupal 8 will be even more reliant on its own
APIs
23. New in Drupal 7
• Besides 190 new hooks
• More granular control of processing order
• 12 levels of preprocess function minimize
can’t get there from here issues
• SimpleTest framework in core
• Generally more consistent
24. So, What’s it Good For
• CMS
• WEB based applications
• Front ends to dedicated apps
• Islandora
• RDF
• Multi-output (XML, etc.)
• Data apps
• Anything
25. That’s All
• api.drupal.org
• Cary Gordon
The Cherry Hill Company
Los Angeles, CA
310-397-2999
cgordon@chillco.com
highermath (Drupal, irc, twitter, etc)
• BoF this afternoon