Archive for May 14th, 2007

NaPoWriFo

May 14th, 2007 by daryl

Well, I didn’t manage it. For the first fourteen days of April (and a day or two before that, even), I wrote at least a poem a day, and not all of them made me want to vomit. Then real life intervened, and I spent a lot of time in the car and hanging out with my extended family during the days surrounding Mom’s death, and I missed a couple of days. And then my work schedule ramped up so that I was (and am) spending the couple of hours of more or less free time I had been using to write in the evenings to work instead. Excuses, excuses. Rather than feeling too bad about it, I’m cutting my losses, acknowledging that I think I may have a few solid first drafts out of the experiment, and suggesting that I participated not in NaPoWriMo, but NaPoWriFo (fortnight). Wheeeee!

Flexible Drupal surveys

May 14th, 2007 by daryl

A few weeks ago, my company needed to publish a survey with a pretty flexible layout. Had we been constrained to the one-field-per-row constraint that Drupal’s survey module allows for, we would have had a very long an ugly form when in fact what we wanted was a nice tidy grid of small form controls that was much less imposing for users to consider filling out. So I hacked our old version of the survey module (for Drupal 4.6) to add a “layout” field to the fields tab for a survey. In the layout field, those who can administer surveys can specify markup and drop form fields into the markup using numeric placeholders wrapped in curly braces. Surveys for which no layout is defined use the default layout with numeric field weighting. I’ve submitted a patch to incorporate this functionality, and you can find the bug report with attached patch here if you’re in need of such functionality before the patch gets review or if the survey module developer declines to integrate it. The patch is for Drupal 5.x.

On a related note, I created a patch for the forms module that lets you add HTML between form elements. This hack/patch arose out of a need to stick a quick text snippet between two fields, where the snippet couldn’t be contained gracefully in the “description” line of the topmost of the fields. I add a form field type “html” that spits out whatever HTML you specify. I wrote this code (or the old version of it; this patch too is for Drupal 5.x) when my company needed explanatory HTML between two fields but the need to manipulate the form fields themselves hadn’t arisen yet. This functionality is good for insertion of quick snippets of HTML, where the first patch I mention above is best for layout overhauls.

Both patches probably represent security risks on sites that allow non-administrators to create forms or surveys, as I’m not (as yet) filtering content, so anybody who can create a survey can add arbitrary HTML. So apply the patch with that in mind.