Drupal

How to generate an image derivative for an image style by visiting a URL

Recently I was adding a photo gallery page to a Drupal 9 site. When a photo was clicked/tapped, the link was supposed to take you to a larger version of the image. Instead, to my surprise, it gave a “page not found” error.

Getting HTML5 video to work with iOS Mobile Safari

I’ve been researching issues regarding serving HTML5 video content to iOS devices this past week. Here’s an outline the issues and some concise answers as to how iOS Mobile Safari 6 will handle HTML5 video. This post won’t touch on video encoding.

Mobile Safari’s QuickTime component does not handle HTTP requests the same as it does normally, say for a web page. Instead

Rules-provided entity variables: Where are my field properties?

At times I am confused by behavior in the powerful Rules module. Sometimes Rules data selectors for entities have their fields listed and sometimes they do not. I did not find documentation about this behavior.

So I dug through code…

Taxonomy Views Browser of Arbitrary Depth

Here’s a way to create a View (Drupal 7, Views 3.x) that lets you browse an arbitrarily-deep taxonomy hierarchy. With this type of browser you can link, oh, say, a large collection of videos, or photo galleries, or any kind of huge list of content categorized in a nested tree.

First, an simple static taxonomy term browser:

Add or remove fields in a Views display and override the Defaults display

A quick tip for Views newbies…

In Views 2.x (Drupal 6.x), if you want to add or remove fields in a Views display, and you want that to override the Defaults display instead of updating it:

  1. In the display, click the Rearrange button next to Fields.
  2. Click Override, then Update.
  3. Add or remove any fields you want.

Drupal Queue API example: enqueue in form submit handler, dequeue when cron runs

Need to store up some items and process them en masse in a cron job? That’s a perfect use case for the Queue API (for Drupal 7+) or the drupal_queue module (the backport for Drupal 6).

Concrete example: One of our consulting clients was using a synchronous webservice for their retail store locator. We needed to create a form where store owners could change whether they’re listed in the store locator. When a store owner submits the form, should she have to wait around while our site sends her change to the store locator webservice? We didn’t think so. So we decided to use Drupal’s Queue API, which lets us save up all the store owners’ changes and send them to the webservice in a batch.

Here’s a simple example of adding items to a queue in a form submit handler and processing them in the next cron run.

ctools Modals and Vertical Tabs

The Chaos tool suite (ctools) is collection of useful methods intended to help Drupal developers create complex interfaces without duplicating too much effort.

Drupal 7 introduced a new Form API element: Vertical Tabs. When you set a parent element as this Form API type, then any child elements that are of type fieldset are displayed as vertical tabs instead of as in the traditional fieldset. Unfortunately for us developers, the documentation does not provide an example of how to use Vertical Tabs properly, but with some trial and error you can do it.

However, this new Vertical Tab Form API element doesn’t work in modal multistep wizard forms created with ctools.

Git-ing Drupal contrib patches done

In not-so-recent news, Drupal migrated the drupal.org project repository from CVS to Git in late February, 2011. My experience with Git previous to this has been as a user fetching source code of x.org, mesa, dri, and other various Linux and Unix projects.

As a user, not a developer, I found the Git work flow confusing. I did not need to make local commits and it was hard to wrap my head around bringing in changes from multiple remote repositories.

As a PHP developer, I first grasped the work flow at Columbus GiveCamp 2010 when I needed to make a github account for the branch of the Audio module we hacked on. As well, some Ruby guy had a nice Git work flow diagram, which I promptly forgot all about until the not-so-recent event above.

Drupalcon tidbits

Cool things I learned about at Drupalcon DC include (but are not limited to) the following:

  • There is a Drupal 6 theme starter app whose maintainer is constantly improving it.
  • Usability studies have proven that I am not the only one who couldn’t figure out WTF to do with the welcome screen on my first Drupal install.
  • A lot of the modules that seem like they should be in core but probably won’t be in Drupal 7, are left out because Token is unlikely to be included and many of them rely on Token.

As usual, more coming…