david's blog

Upgrading modules to Drupal 7

Okay, so it's no D7CX or anything, but I just spent the weekend upgrading my three little modules to Drupal 7:

This was fantastic experience for me, because I had to do a lot of study of Drupal 7 that I had previously been putting off; for example, learning the new database API was a big step. I found that the excellent Coder module did a lot of the work for me, but there were a few things that it just couldn't cope with. So, I'm making a list of what to do after running coder module for next time:

  1. Search for any "todo" text, and do what it tells you.
  2. Switch to the Drupal 7 javascript implementation.
  3. Search for any code using "db_placeholders" - coder does NOT deal with those queries.
  4. Search for paths that have changed, such as admin/user is now admin/people.
  5. Check the hook_theme and theme_whatever functions VERY carefully.
  6. Make all your simpletests pass - you do have simpletests already, don't you???
  7. Review the doxygen comments on all your functions.

That really about covers everything I had to do to upgrade my modules to 7.x. Of course there were a few hooks that had changed bits, and various odd errors, but nothing too trying.

If there is one thing this process illustrated, it was the immense desirability of tested code. Read more »

Quick and dirty migration to new Aegir platform

I've been trying out the managed Aegir mini offering by Omega8.cc, and been quite happy with it. A few days ago I got a message that I needed to migrate them over to another platform because they weren't on a Pressflow-based Drupal 6 platform. These are sites that I haven't touched for a long time - apparently, in fact, since before I started using Pressflow. So then: how to migrate the sites without spending a lot of time on them? I decided to just move all the code into each site's folder and then migrate. Here's how to do it:

  • Backup your sites. It's just a good idea.
  • Log in as user 1.
  • If there are any modules that EXPECT libraries to be in your sites/all/libraries folder, you must first COPY those libraries over to your site's folder and then redo the settings. The "Drupal for Facebook" module, for example, wanted me to edit the settings.php file, but mine was not writable, so a little drush vset worked just as well:
cp -R sites/all/libraries/facebook-php-sdk sites/[sitename]/libraries
drush vset fb_api_file 'sites/[sitename]/libraries/facebook-php-sdk/src/facebook.php'

  • Move all your contrib modules, libraries and themes out of sites/all and into your site's folder, e.g.

Drupal 7.x usability

My wife just started using a freshly-installed Acquia Drupal 7.2.2 site. She's very web savvy, but not familiar with Drupal. Here are some quotes: Read more »

Quick add new ticket form block in OpenAtrium case tracker

One of the things that annoys me about all ticket management systems is the amount of time that it takes to add a new ticket. Click the project; click for a new ticket; wait for the page to load; enter a title; select a priority; assign to a user; select other options; enter a longer description; click "Save"; wait for the page to load; rinse and repeat. That's a lot of overhead just for adding a ticket! I've tried unfuddle, basecamp, jira, and openatrium, all with the same complaint.

For a while I experimented with scrumy, which is a fun ticket management solution for small projects, but not being able to have longer descriptions and discussions makes life a little difficult.

So, we're using OpenAtrium now, and since it lives on my server I can customize it. One of the first things I did was add the formblock module and set it up so that I could add a case (that's atriumspeak for "ticket") from any dashboard. The setting is on the content type administration page for each node type; so in Atrium (once you have permissions set) you can just go to admin/content/node-type/casetracker-basic-case and you'll see the option.

You see that picture of a form? Yah, that's a block now. Thanks Nedjo and Mikey P!

Of course, I had to do some tweaking in order to get it to work just right. Adding the block to the right context was the easy part. Read more »

Holidays using Calendar module for Drupal

I often use the calendar module for my Drupal sites, and I often want to put holiday information in them without making a whole bunch of events or doing weird stuff with Javascript. With a very small patch to add a date class to table cells generated by calendar module, this is possible with pure css. Since every day of the year has a distinct class in the format Dec-3, you can simply address each one through css:

td.Jul-4 {
  background: url(flag.jpg) center center no-repeat;
}

If you want to add a nice textual banner at the top of each holiday on the calendar, just use the CSS :before pseudo property:

td.Jul-4:before {
  content:"Independence Day";
}

With a little bit of styling, that banner can look really good. I like using partially transparent images as backgrounds, since I don't want to cover up the images in the table cells:

div.calendar-calendar td:before {
  border-bottom: 1px solid #e0e0e0;
  border-right: 1px solid #e0e0e0;
  float: left;
  font-size: 9px;
  font-style: italic;
  padding: 1px 5px;
  text-align: center;
  width:69%;
  background: url(bg-top.png) top left repeat;
}

All you need to do to make sure your css appears all over your site is add it to your theme. If you're using multiple themes and you want an across-the-board solution, just add it to your glue module:

function glue_init() {
  drupal_add_css(drupal_get_path('module', 'glue') .
 Read more »

Nine-pointed star using GIMP with spyrogimp

Ever want to make a nine-pointed star using spyrogimp? Unless you're better at straight math than me, it's a little tough to figure out the numbers. Here are some that work: Read more »

Why is all my CSS gone? ...drush cc

So, there are probably many reasons you might be getting a page like this one, with no CSS whatsoever. I've discovered a few. My most recent surprise was drush cc.

At least in my case, it looks like clearing that "css and js" cache is a bad idea on a site with page caching turned on, because anonymous users will see the WSOC (white screen of confusion - just a little shy of the WSOD).

But, it should be noted that in some cases you want to see what Drupal spits out before you hack it into submission with CSS, and there's no need to be clearing database tables for that; just use the stark theme.

Reasons why your CSS disappears:

  • Some weird browser issue - try ctrl-f5
  • Clearing the "CSS and JS" cache using drush cc on a site with page caching - clear the whole cache instead
  • Enabling the stark theme - you may want to do this to check out what Drupal looks like before you theme it

Upgrade script for Aegir alpha15

Kudos to the Aegir project for Aegir's alpha15 release, and especially Miguel for the contribution of a long-anticipated (by me at least) upgrade script. As before, you must read and carefully follow the version-specific upgrade notes at the bottom of the Aegir upgrade instructions, but after that the script automated everything. I was upgrading from the rather antiquated alpha7, and aside from one very minor issue (which was apparently fixed before I posted it to the queue, hehe) everything went smoothly.

Well... almost.

For what it's worth, moving an aegir installation over to a completely new server at the same time as I did the upgrade was... a bit painful. I forgot the aegir_root password. I typed it in wrong - 6 times. I neglected to add aegir to the sudo users. My server didn't verify. My sites didn't open. A few deep breaths and a few restores from backup later, everything works. Now I have my web server running on a nice little mac mini.

Failed to open stream: Permission denied theme.inc on line 155

Maybe you're having the same problem that I just did:

warning: include_once(./) [function.include-once]: failed to open stream: Permission denied in ...\theme.inc on line 155. warning: include_once() [function.include]: Failed opening './' for inclusion (include_path='...') in ...\theme.inc on line 155.

If so, check your theme's .info file - you may have misspelled the theme engine. It needs to be as follows:

engine = phptemplate

Make sure it's all in lowercase.

Syndicate content