Drupal Blog by greg.harvey

Piping A File In To MySQL

Our use case here is if you have a lot of data you want to insert in the MySQL - data that you might usually use the Drupal UI for, but there's so much of it you'd rather not if you can help it!

The example here is for a client of ours. For this particular client we have to launch a few new sites a month, each one comes with a new access list of email addresses to add to the Drupal "Access rules" page. There's no bulk upload, and doing these one by one with the UI is laborious, to say the least!

Look, Drupal 7!

This is now my first Drupal 6 to Drupal 7 upgrade. Not without hitches, but all in all not too painful. Hope you like the new look. As dedicated readers may know, I never stick with the same theme between major Drupal releases, more often than not because my previous theme was never ported and I can't be bothered to port it myself. The new theme is the rather pretty Corolla, which you can find here:

Here are some Drupal 7 upgrade notes and links others may find useful.

Security Releases Don't Work

Wow, long lapse in posts there. Sorry folks. On with the show:

Here's the problem. The Drupal security team do a fine job, following up on reports, auditing contributed modules with a point release to check for security weaknesses, working on core. It's all good, except for one thing:

Contrib release process.

Panels 3 And The 960 Grid System

This post was going to be longer, but I just lost the entire completed document because the worst (and probably most expensive at $15/day, yes DAY) mobile Internet provider in the world, EVER, just dropped my connection mid-submission and for the zillionth time today. So you'll have to make do with an angry and hurried synopsis of what I would've written.

Drupal 7 Cheat Sheet: The Database

This is a quick post while it's fresh in my head, regarding porting your contributed modules to the Drupal 7 API. This post specifically focusses on database manipulation and provides the like-for-like changes. If anything here is wrong, or could be done better, please let me know!

First up, individual results:

* Remember this?
$value = db_result(db_query("SELECT some_field FROM {some_table}"));

* Forget it! It now looks like this:
$value = db_query("SELECT some_field FROM {some_table}")->fetchField();

Scared Of Features? Don't Be!

I'm an experienced Drupal developer. I've been embedding stuff in code for ages now. Views, Panel pages, ImageCache presets, even putting CCK content type exports in to hook_install() implementations just to try to keep stuff in code. Many of you are probably in the same boat. Keeping stuff in the database brings all sorts of ugly deployment and performance issues, so we avoid like the proverbial plague.

Cleaning Up After Migrating To Drupal

We have just finished a migration job for a client of ours from an old .Net system in to Drupal, the last task of which was to write some Apache mod_rewrite conditions and rules to deal with the URLs of their old website. This proved to be more trouble than I thought, mainly because I struggled to find examples of how this might work.

Firstly, the ground work. The URL pattern to be redirected looked like this:


Multilingual Drupal: Some Dos And Don'ts

So we've done all French sites before. And we've done all English sites before. But a recent project was our first real forray in to multilingual sites and it's an e-commerce/Ubercart job! Talk about gluttons for punishment!

There are bags of tutorials, so I'll keep this short but sweet. A list of dos and don'ts from our painful, recent experience:

  1. Don't change the default language after initial set-up. Set your default language right at the start and don't mess with it. Ever.

How Drush Make Just Changed My Life

Note: Apparently it works fine with Windows too! See comments.

I'm pretty excited right now. I just tried drush make for the first time. Download it here:

That's an order! You'll need drush too, if you don't have it yet (in which case, shame on you ... call yourself a Drupal developer?!)

Wrapping Up: A Linux Script For The End Of The Day

Here's another one of my little Linux admin scripts for all you Drupal developers out there. It's a Linux shell script requiring Drush, MySQL and Subversion, but could be easily modified to work with other databases and repositories and should work fine on a Mac, I think.

Drupal Help Haiti: Day 4

Ups and downs again today. Some strong support from Europe again, but the US has yielded no strong continuation. Don't get me wrong, we have people in the US interested in helping, and we're extremely gratefful for that, but we don't seem to have a US project "driver", so it seems to drop to pieces.

I managed to make some good progress this morning with Feeds, Views and Panels. And numerous people added to that progress throughout the day, so we actually got a reasonable amount done.

OpenID, I'm Starting To Understand

Important edit: Seems it doesn't work with Google Apps accounts - apologies to Zach in the comments, you were quite right. I'm revising this post. However, it does still work as described with all Google Mail domain accounts (e.g. personal Google accounts).

So, OpenID. Been about for a while. I kind of knew how it worked. I also knew I had dozens of OpenIDs, all in places of no use to me whatsoever that were generated automatically when I signed up for some service or other.

Drupal Help Haiti: Day 3

Having finally sorted out our goals (use the Project EPIC Twitter syntax to get targetted information to people who can help, using Drupal as a tool for managing and organising that data), day 3 started with an ambitious set of tickets:

  • Identify and engage with an SMS gateway
  • Configure the Feeds module to create nodes
  • Create views for displaying aggregated tweet nodes
  • Collate list of Haiti resources
  • Install Backreference module

Drupal Help Haiti: Day 2

So we've started the second day of this project. Our mission is starting to become clearer.

Yesterday, within 7 hours of the effort really getting under way, we had a server, a team, an installation of Development Seed's excellent Managing News, but no real clue about what might be useful. There was a lot of chat about mapping, but Robert pointed out the UN are already doing a stunning job of mapping the crisis and also need volunteers. So dividing the Drupal geo community amongst us would be damaging and stupid.

Then we found this:

Helping Drupal Help Haiti

You may have noticed a degree of Haiti noise on the Internet today. Michael Caudy kicked things off and Robert Douglass quickly joined him on the campaign trail to get Drupal developers on board to create a Drupal website to help the aid workers hard at their tasks in the aftermath of the earthquake there.

Drupal And Linux, A Deployment Script

Quick post today, no politics *whatsoever*. ;-)

I just wrote another little batch script for deploying my Drupal sites from local to stage. Before I post the code, here's the workflow here in our office at CMS Professionals:

  • Code is stored in Subversion away on the Internet (svn.cmspros.co.uk)
  • Each developer has a working copy on their laptop
  • Database during development is held on central (dedicated) CentOS/MySQL machine on our office LAN

Duplicate Issues, Are They Really A Problem?

We often see people getting berrated for posting dupes, sometimes deservedly. Let me say from the get go that I do not, in any way, support the needless creation of noise in issue queues by people who are so lazy as to have made *NO EFFORT WHATSOEVER* to find a solution. These people are a problem, and they waste everyone's time. But shouting at them does nothing. They won't change. Blanking them is the best approach. Close the issue with a link to Google or something.

Drupal Services And The Dreaded Clock

Quick post this evening, because I'm stopping for the day. Just a troubleshooting tip for web services. We use the excellent Drupal Services module quite a lot for integration work. Take a look, if you don't know it:

Anyway, we always switch on the full security options, which are great for securing the API but stacked full of nasty gotchas. I had a new one today and I thought I'd share.

Part of building an authentication token for the Drupal Services module is adding in a timestamp. The code we normally use looks like this:


Missing Anonymous User

I've spent the last few days wrestling with an evil bug. I had a content type, called Card, which I could create fine when logged in as any authenticated user of any role. All cool. I should also be able to create this content as anonymous.

Indeed, going to Create Card (node/add/card) was fine. I got the form, filled it in, but then nothing. Page Not Found where the created node was expected. The node simply wasn't created! But there were no warnings or errors. Big fat nada.

The Contrib Conundrum

Edit: Please read this blog post, but also please jump in on this thread - the idea is already proposed but needs community support:

And so again today it happened, as it does so many days. Someone needs to be able to do something. They Google. They search Drupal.org. They find nothing but a few open issues or an unsuitable/unsupported contrib module. They're a developer, so after an hour of searching they think "ach, to hell with this - I'll just write something".

I happened across a wee bug in Views 2 today. I think I've noticed it before, and I'd be a monkey's uncle if it isn't already in the queue, but this is a synopsis:

If you expose the Node Type filter in Views 2 and set it to "Optional", but also with "Limit list to selected items" checked, you might expect it to continue to restrict the results to the selected items it refers to, right? (Well I did.) It does not. If your use selects the "< Any >" option from the resulting UI they will get *everything*


Cleaning Up Node Edit Forms

Every time you build a new application in Drupal you *always* have to carefully govern the number of options available to normal site editors, or their heads will explode. (Literally. I've seen it.)

Almost every module you install will put something more on the node forms, until you end up scrolling forever just to reach the Save button. Not to mention most of this stuff you won't want them playing with anyway.

Drupal 6.x And Ubuntu 8.04 (Hardy)

A few weeks ago I wrote a post about how to bring a stock CentOS 5 server up to spec to run Drupal 6. It seems only fair I do the same for Debian and Ubuntu, since it seems they too are not without their little issues when a stock install. This quick post was written after configuring a server running Ubuntu 8.04.2 (or Hardy Heron, as it was codenamed).

The first (and main) problem with a stock Debian install is it does not include the necessary GD support for manipulating images. There is a long internal squabble in the Debian ticketing system here:

Do We Have To Put Corks On All The Knives?

Yay! My first blog post with the 7.x tag! It's coming up fast, folks... Shame this one is a gripe.

Courtesy of an issue I raised some months back regarding the update system registering updates in the system table, even if they fail, I came across an interesting and (IMHO) bad decision regarding update.php in Drupal 7:

Sometimes The API Just Won't Do It

So I've been having lots of fun (read: horrible pain) this week thanks to some quirks of Drupal that only really present themselves when you are looping through, loading, saving and manipulating nodes quickly. The scenario for this sort of thing is normally (yup, you've probably guessed it) importing.

Theming Ubercart, Some Tips And Tricks

First, a note on "compatibility" (for want of a better word). This piece is written after some extensive theming work in Ubercart 5.x-1.7. Much of this is still useful information for the Drupal 6.x version of Ubercart, but it may not be wholly accurate.

I should also note that this is not really a hand-holding step-by-step piece. It's more for people who are already pretty familiar with theming Drupal and just want to know where to look.

Database Download Script

Just thought I'd throw this one up there. It's a Linux bash shell script I wrote this morning. You know when you want to take a copy of your production database down to localhost for testing? Not rocket science, but a bit of a pain. This dramatically speeds things up.

In the past I've copied and pasted an old shell script that's been kicking around on my hard disk for years, changed the details and run it. Well this morning I thought "Enough!" I tidied it up so it accepts arguments and even has a --help argument response. This is the code:

if [ $1 = "--help" ];

Subscribe to Drupal Blog by greg.harvey
© 2010 Greg Harvey. Drupal theme by Kiwi Themes.