Drupal is usually great at handling special characters. Unlike other systems everything has always worked out of the box for me in Drupal. Recently however I did end up with an edge case involving mail headers.
What I wanted to do was to send a nicely formatted From-header so the site name would show up instead of just the e-mail address. The header could for example look like this: From: Mÿ Fäncÿ Sitë <mail@example.com>
As e-mail headers can only contain US-ASCII characters any special characters needs to be escaped, but Drupal does this automatically, right? Yes and no. Drupal does run all mail headers through mime_header_encode() to escape non-US-ASCII characters. In our case that results in:
From: =?UTF-8?B?TcO/IEbDpG5jw78gU2l0w6sgPG1haWxAZXhhbXBsZS5jb20+?=
It's a little more garbled than it should be. A correctly formatted header in our case would be:
From: =?UTF-8?B?TcO/IEbDpG5jw78gU2l0w6s=?= <mail@example.com>
As you can see the "name" of the from-address should be escaped with all the UTF-8 magic, but the e-mail address itself should not be encoded. E-mail clients handle these malformed headers badly—often showing no From-name at all or showing a part of the following header as the From-name.
The solution is to do the encoding yourself before sending the header off to drupal_mail(). In our case it would look like this:
$from = mime_header_encode('Mÿ Fäncÿ Sitë'). ' <mail@example.com>';
This of course means that the name is runs through the encode twice—once by you and once by drupal_mail(). Fortunately, mime_header_encode() is smart enough to only encode strings which contain non-US-ASCII characters and you can safely run strings through it multiple times without risking double-encoding issues.
It's been too long since we had a Drupal event in Copenhagen so on October 3 the Drupal Denmark association is putting on a Drupal Day. It'll be a one-day, free event in Barcamp-style with all kinds of Drupal goodness. Come meet us all, we don't bite!
The day are busy at Hoist. We are ready to launch our new work tool very soon (workshops are held next week with few spots left—let me know if you're interested).
Working on the user interface goodness I needed to execute some javascript immediately after a node has been posted in Drupal. The javascript should not be included on every node view, only the first. The nodeapi's 'insert' operation can't be used to include javascript because there is a redirect after it is processed and the 'view' operation can't tell if a node is brand new or not.
The solution I used is to set a session variable. It feels a little hackish, but it works great.
function yourmodule_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if ($op == 'insert') {
$_SESSION['yourmodule'][$node->nid] = $node->nid;
}
if ($op == 'view' && $_SESSION['yourmodule'][$node->nid]) {
// Insert call to drupal_add_js() here.
unset($_SESSION['yourmodule'][$node->nid]);
}
} Tomorrow I'm doing a Drupal Intro at the IT-University in Copenhagen. It's open to anyone and not just ITU students. If you have been wondering what Drupal is and how to get started show up for a show-and-tell and Q&A. It's bound to be fun.
More information at drupalbog.dk—it's completely free, but we'd like to know how many people to expect. The event is in Danish and starts at 16:00.
It's that time of year again. This will be my third DrupalCon and they have gotten progressively more insane. I bought my ticket way back in October of last year and it turned out to be a good idea. DrupalCon has been sold out for a long time now with over 1300 attendees and tickets being sold on eBay. We have a nice little Danish expedition heading to DC. I believe there are about 10 of us from the Danish Drupal Community going which is quite an increase over the 4 Danes in Boston last year.
If you are there look me up. I'll be the one with the exploding head who can't handle all the inputs. Just take a look at the massive schedule.

Three weeks ago I attended DrupalCamp Copenhagen and it was a blast. There are rumours of a new event at some point in the spring and if you have even the slightest interest in Drupal you should show up. No doubt about it.
As an experienced Drupal developer I arrived mostly for the run down of the Apache Solr Drupal integration and other more advanced sessions, but what struck me as the real value was the work done to teach those who were just getting started with Drupal.
These days I do Drupal all day, every day and I work with some extremely talented people. It's easy to forget that we were all beginners at one point and DrupalCamp reminded me. There was a very large group of Drupal newcomers and they were all attentive, interested and before all motivated to learn how this thing we call Drupal works.
The organizers had done a good job assembling a track for beginners. There were general intros (a session called "Don't hack core" - matching one of the tshirts), intro to theming and I did an intro to Views 2 and CCK 2. However my favourite session was "How do I?" by Camilla and Thomas from Peytz. I have worked with both of them extensively and they're Drupal rockstars, but for this session they held back. After a quick demonstration of how to make a tennis club website they started to take questions fro the participants.
Many of the people in the session were in the process of making their first Drupal website and they all had questions. How do I upgrade my modules, how do I modify themes downloaded from drupal.org and so on. There were a handful of more experienced Drupal developers and themers in the room who sat down and helped the rest. There was a great vibe in the room and it gave me energy to see all these people so motivated about learning how to do Drupal.
The photo above is Thomas during the "How do I?" session. I've put up a few more photos, but I didn't take many since I only brought a bulky film SLR with me.
DrupalCamp Copenhagen is happening this weekend on the 15th and 16th. It's the first major Drupal event in this little country, but there are still over 100 people confirmed and the camp is totally sold out. I'm getting jazzed up about attending because I share office space with the main organizer morten.dk and he's been working very hard on setting up this DrupalCamp.
I'll be there along with Hoist and rumour has it that I'll be doing an introduction to Views and CCK, the two most important Drupal modules. It will be for complete beginners and I will show you how you can set up a simple book review website including editorial workflows without writing a single line of code.
If you're already registered Hoist is hosting the pre-registration (get your badge and a beer) on Friday. Stop by Hoist HQ from 16:00. I've got business in another part of town, but will be there from 17:30 or so.
This is a very long entry. Don't say I didn't warn you.
On both the videoblogging group and the Show in a Box (SIAB) working group the question of How do we best present video on the internet? has come up multiple times over the past 3-5 months. It is a vital question for the average videoblogger who wants to improve his or her site and especially for groups like Show in a Box which are trying to create software and designs that help present videos in their best light.
However, the discussions on those lists are mixing together three separate issues to answer the question of how to best present video on blogs. I will outline the three issues below and attempt to explain why it is important to solve these separately.
I have taken over as maintainer of the pingback module for Drupal. Long-time readers will know that back in 2004 I wrote extensively about using pingbacks as a basis for distributed commenting. Hopefully, I can now pick up that old torch again. Using Drupal as the framework does make many things much much easier.
The pingback module was originally developed by Leontius Adhika Pradhana but he does not have time to maintain the project. I took over last week and I have just now released a Drupal 6 version of the module.
I have some non-sweeping plans for the module. The interface text can be improved and setup can be made more simple and it is important for me to implement a hook and a trigger so other modules can act when pingbacks are received. The last parts are needed to make it possible to create for example a video commenting module that catches video files from pages that link to your pages.
The pingback module has of course been installed here on solitude.dk so ping away!
I have just updated the Embed QuickTime plugin that allows you to post QuickTime easily to webpages. The biggest change is that the plugin now comes with 'share' code giving your visitors Copy & Paste code for posting your videos to their own sites. Yes, like YouTube without the ugly Flash. Additionally the Metadata plugin is now included in the download and you no longer have to download it separately to start using the advanced settings.
The Drupal 6 module and the Wordpress plugin have been updated in the same go.
To celebrate I give you a birdie you can share:
This is the personal website of Andreas Haugstrup Pedersen: commentary on media, communication, culture and technology. Read more»