Excellent Drupal 7 introduction for experienced developers

Recently, I started working with one of the best Titanium Titans on one of my mobile projects. For those people who aren't familiar with the concept, Titans in the world of Appcelerator's Titanium are the thought leaders of the project and, obviously, wicked smart developers. In one of our conversations, he mentioned that a lot of his clients need Drupal expertise and want to use Titanium with Drupal 7, and he asked me about a good introductory book for himself.

My first suggestion was Pro Drupal 7 Development, but after reconsideration, I wasn't sure if that was the best book to get him familiar with the rich feature set of Drupal. Although it explains the building blocks of Drupal itself very well, it doesn't provide guidance on the tools, tips & tricks and, most importantly, most used Drupal 7 modules.

For a developer with a pre-existing intermediate to high level of programming expertise who wants to start getting a solid feeling for Drupal 7, I'd recommend Drupal 7 Development by Example instead. I particularly found the discussion of both Drupal basics and 'must-have' modules interesting, which of course features the creation of custom content types and a quick introduction to module development, as well as usage examples for modules such as the Media module, Colorbox, Webform, Views, Views Slideshow. Since the book covers a lot of ground, you shouldn't expect the author to go into too much depth in each area, but anyone looking for a great introduction to the power of Drupal and it's powerful world of modules, this book is an excellent choice.

Drupal Mini Series: Drupal 7 Multi-sites Configuration

If you've ever read all the way through a Drupal book, you will have found those short chapters at the end that mention some of Drupal's more advanced features such as multi-lingual sites. Whenever you setup a Drupal installation that requires the word "multi", you'd wish that those 2 short pages would be filling a whole book. That's exactly what Packt Publishing has done with a cool new series called "Drupal Mini Series": A compact, roughly 100 page long book about a single topic that explains all aspects of it in the level of detail you were looking for.

The first one I read was Drupal 7 Multi-sites Configuration, which explains (in the right level of detail) how to run multiple websites from a single Drupal 7 instance, including the often missing information on server setup, virtual host configuration and how to update a multi-site.

I've been a big fan of Packt's Drupal books for a while; and especially of Matt Butcher. There aren't that many tech writers out there who can actually explain complicated systems in an easy way. Get your copy here, there are currently two more titles available (Drush User’s Guide and Drupal 7 Multilingual Sites), with hopefully more to come soon.

Drupal 7 Multi-sites Configuration

Installation and Theming for jPlayer for Drupal 6: An HTML5-based mp3 player

One of my clients' website viewers are moving from desktop to mobile devices. And of course, he is showcasing a lot of music on his website, currently being displayed using a Flash frontend player, which can't be viewed on iOS devices. To fix that, I recommended switching to jPlayer, a HTML5-based player that uses Flash as a fallback for browsers that don't support it yet. This post is intended to provide the missing pieces of information for those of us still, ahem, stuck with a Drupal 6 installation (the jPlayer documentation primarily focuses on Drupal 7).

Installation

Here's a quick overview on how getting jPlayer running on your Drupal 6 installation:
  1. Install Jplayer module for Drupal 6 and enable it like any usual module
  2. Download the jPlayer plugin version 1.2.0 from here or directly here. The most current version (jPlayer 2.0.0) is not compatible with the Drupal 6 jPlayer module. Extract the contents in 'sites/all/libraries/jplayer'
  3. Go to the configuration page of the jPlayer Drupal module (admin/config/media/jplayer) and specify the path for the jPlayer library as configured above ('sites/all/libraries/jplayer')
This should be all that's involved. You should be good to go to use jPlayer in your content types (select it under "Display Fields" for your content types that have MP3 files uploaded) or use it in Views.

Theming

Of course, it would be great if we could use jPlayer for just any node that has an MP3 file attached to it, either in our theme files or anywhere else we want to manually display an MP3 file using jPlayer. I wasn't able to find the theming documentation for it on the module page, so here's a quick code snippet to get you going. For this example, I'm assuming that you have a content type called 'song' setup, every song node has 1 MP3 file associated with it.

$nid = 100;                       // Example node id 100
$node = node_load($nid);          // Loading the full song node
$type_name = 'song';              // Machine-name of the node content type
$field_name = 'field_song_file';  // Machine-name of the CCK field you use to store the MP3 file
$jplayer_data = array(
  '#field_name' => $field_name,
  '#node' => $node,
  '#type_name' => $type_name,
  '#theme' => 'jplayer_formatter_single',
  '#item' => $node->{$field_name}[0],
);
print theme('jplayer_formatter_single', $jplayer_data);

jPlayer

Drupal 7 Push Notifications: How to register a device token using services

I recently published a module on drupal.org that allows site admins to send push notifications to users that have registered their mobile device tokens and got asked how users can register a device token. The Push Notifications module for Drupal 7 can be found here: http://drupal.org/project/push_notifications. Here's a quick tutorial on how to register a token through the services interface.
  1. Navigate to the Services admin interface at admin/structure/services: http://cl.ly/3F1429021N2W2y1s2j15
  2. Add a new services endpoint. For this example, I'm going to create an endpoint called "mobile_data". This will be the base URL for your services, e.g. http://www.yoursite.com/mobile_data. See http://cl.ly/0j3o0B102j1A1a46183C
  3. You should see your new endpoint listed at admin/structure/services: http://cl.ly/0U0f0p470S1e2J1o0A29. Click on "Edit Resources" for that endpoint
  4. On the "Resource" page for that endpoint, you will see a list of all resources. Make sure "push_notifications" and "create" underneath it is enabled: http://cl.ly/2m0C0Y393y0P2f3L3016
  5. Make sure to enable all parsing types you want, e.g. if you're sending url-encoded data, make sure it's enabled: http://cl.ly/1C3K3S3y372o140x1K1c
These are all the steps you need to take to enable your services endpoint. You can then register your device token at http://www.yoursite.com/mobile_data/push_notifications. You should use a POST on that URL and pass two arguments:
  • Token: The device token (argument name: 'token')
  • Device Type: The type of the device (argument name: 'type', options are either 'ios' for iOS devices or 'android' for Android devices
A very helpful tool is the Cocoa REST Client.

Picking the best theme for Drupal 7

Just like everyone else these days, I am jumping on the Drupal 7 bandwagon for my newer projects. And every time, I come across the question which theme to use. By default, I gravitate towards Zen. I know it inside out, it is still the most-used theme across all Drupal sites and it just seems like the right way to go. I'm not a big fan of splitting up my css into tens of stylesheets, but I can go with the flow.

Then there is Fusion, which is "a simplified 960px" grid theme and #2 on Drupal.org. As a developer, I often come across these red flags that should be slightly orange ones at best, but I just can't stop including them into my decision making process. With Fusion, that would be the fact that it is a theme by "Top Notch Themes". Nothing wrong with that company, but it's just that: there's a company behind it that sells most of their other themes. Other than that, it seems to be a perfectly fine theme.

And then there is the new kid on the block: Omega. With a cool name like that, how could you say no (even cooler: the core and starterkit themes are called Alpha and Omega => geek points for that!). Something that I need for my projects is to have most of the configuration to live in the code, not the database, for a lot of reasons other than "versionability". And from some developer friends, I've heard that Omega's configuration lives mostly in the database. That being said: the usage statistics for Drupal 7 are crazy good: http://drupal.org/project/usage/omega.

The theme package with the fanciest HTML 5 logo is AdaptiveTheme and its numerous sub-themes and sub-themes thereof.

Enough said, let's get to the trial & switch-to-another-theme part :)

Just like everyone else these days, I am jumping on the Drupal 7 bandwagon for my newer projects. And every time, I come across the question which theme to use. By default, I gravitate towards Zen (http://drupal.org/project/zen). I know it inside out, it is still the most-used theme across all Drupal sites and it just seems like the right way to go. I'm not a big fan of splitting up my css into tens of stylesheets, but I can go with the flow.
 
Then there is Fusion (http://drupal.org/project/fusion), which is "a simplified 960px" grid theme and #2 on Drupal.org. As a developer, I often come across these red flags that should be slightly orange ones at best, but I just can't stop including them into my decision making process. With Fusion, that would be the fact that it is a theme by "Top Notch Themes". Nothing wrong with that company, but it's just that: there's a company behind it that sells most of their other themes. Other than that, it seems to be a perfectly fine theme.
 
And then there is the new kid on the block: Omega (http://drupal.org/project/omega). With a cool name like that, how could you say no (even cooler: the core and starterkit themes are called Alpha and Omega => geek points for that!). Something that I need for my projects is to have most of the configuration to live in the code, not the database, for a lot of reasons other than "versionability". And from some developer friends, I've heard that Omega's configuration lives mostly in the database. That being said: the usage statistics for Drupal 7 are crazy good: http://drupal.org/project/usage/omega.
 
The theme package with the fanciest HTML 5 logo is AdaptiveTheme (http://drupal.org/project/adaptivetheme) and its numerous sub-themes and sub-themes thereof.
 
Enough said, let's get to the trial & switch-to-another-theme part
Picking the best theme for Drupal 7

Live Blogging from DrupalCon Chicago: JavaScript in Drupal 7

Presenters: Kat Bailey

Drush Make Demo File: katbailey.net/resources/d7js

New Ways to add JavaScript in D7:

  1. Add it in the .info (within a module, not just the theme)
  2. drupal_add_js: Function changed a bit since D6, allows additional of external JavaScript
  3. Add it in a Render API: Using the 'attached' property

Altering JavaScript in D7:

hook_js_alter allows coders to change any JavaScript file

JavaScript Libraries

  • hook_library: Defines your JavaScript library
  • hook_library_alter: Alter an existing library

Live Blogging from DrupalCon Chicago: Aphorisms of API Design

Presenter: Larry Garfield

  • A good example: noad_load_multiple: Wrapper by node_load in Drupal 7: It doesn't make a difference if you're loading 1 nore or 100 node
  • A not so good example: Search API. Only allows to search for one entity at one (i.e. the module doesn't allow the user to search for users and nodes)
  • Good APIs are picky: Instead of returning nothing / NULL, good APIs return exact error message (think of the "Invalid parameters supplied on line 2933 somewhere in forms.include"
  • In you rown module: don't use undocumented APIs and don't hardcode code that shouldn't be
  • A UI is not an API
  • A website is also not an API: An API does not need a website
  • 3 implementations should be required: 1. Simpletest. 2. Drush. 3. Webform

Live Blogging from DrupalCon Chicago: Media in Drupal 7

Presenter: Jacob Singh

  • Drupal 7 offers the new Media module, which replaces all the different media modules from before
  • Media attempts to be a "file browser to the Internet". Modules can plugin to the Media module (e.g. YouTube, Flickr etc.)
  • Main advantage of Media is that the interface and API is consistent
  • Media has security advantages that allows anyone to embed images and video that circumvents the issues of malicious tags in media files
  • The Media (module) attempts to be the default file-management tool in Drupal 8

DrupalCon Chicago

I'm at my first DrupalCon in Chicago. Yeah. Compared to the Drupal Camp in New York, this seems HUGE. If I actually used Twitter, I should have poster this there. But hey.
DrupalCon Chicago

New Drupal Module: Privatemsg Bulkmail

One of my favorite modules for Drupal is the Privatemsg module. It's basically the Drupal version of Gmail, including a huge feature set for (almost) any need. For one of my clients, I needed to create a feature set that allows him to send internal notifications. Although the newest version of the Privatemsg module comes with the feature to send messages to specific user groups (in Drupal talk: roles), that feature didn't quite fit the required needs, so I decided to write a contrib module with a larger feature-set: Privatemsg Bulkmail.

The Privatemsg Bulkmail module is intended for site administrators who want to send out an identical private message to a large user base (100.000 users and more). An example use case would be an internal notification to all registered users through a private message.

Here's the description of the feature set:

  • Send out private messages from a specific user (instead of the current user)
  • Define a dedicated bulk message user and prevent that user from logging in (to prevent performance issues)
  • Prevent users from responding to a bulk mail message
  • Include AND exclude recipient group of a bulk mail. Example: Send out a bulk mail to all authenticated users that are not site admins
  • Restrict the recipient group to users who logged in or signed up after a certain date
  • Send an individual test message to a specified user before sending out the bulk mail

If you have a use case for this module, try out Privatemsg Bulkmail and leave some feedback on the issue page.