24th Apr 2012

When developing we tend to use a lot of different domains to do our work on, I typically will use the .drupal top level domain, so my project URLs look something like:


When starting a new project, one of the annoying things that we have to do is create an entry in the hosts file for this domain: project-name.drupal

On Ubuntu there is a really simple way to automate this and give yourself a 'wilcard' DNS entry, so any domain that ends in .drupal will resolve to my local machine. Enter Dnsmasq.


This should work...

Read more

Making the Flag Module's Confirmation form use AJAX

17th Apr 2012

This article discusses how we can use a combination of techniques to take the standard 'Confirmation Form' provided by the Flag module and get it to load in a modal window rather than on its own page. We'll also extend this form slightly to allow the user to include some additional data before clicking 'Confirm'. As an example we'll use the Flag module to create an 'Abuse' flag that will apply to a comment entity - this is intended to allow a user to flag a comment as requiring moderations but before triggering the actions associated with the flag we...

Read more

Render a block programmatically

22nd Mar 2012

This is a real quick one, but so useful! We often want to render a block within content, perhaps as part of a node (maybe in hook_node_view, and then made configurable like a field), but there's no obvious way to do this correctly for any block. Drupal normally renders its blocks per region, so there is no single function to embed a block. I came across this really simple solution by Damien Tournoud in a Drupal core issue, which I feel deserves more exposure:

$block = block_load($module, $delta);
$render_array = _block_get_renderable_array(_block_render_blocks(array($block)));
$output = render($render_array);

That's just three...

Read more

Creating Facebook Canvas Apps & Page Tabs

9th Mar 2012

Facebook integration is obviously starting to become a de facto requirement with most web development projects. In most cases the requirements are reasonably straight forward and involve nothing more than including a ‘Like’ button on content, but what about actually adding your own bespoke content to Facebook like The Guardian – bring on the Facebook Canvas App.

Canvas Apps are essentially just a way of wrapping some externally hosted content and putting this onto a Facebook branded page. We’ll use a basic example of just getting this page onto Facebook as a starting point before starting to explore how we...

Read more