Drupal articles

Automated deployments using Aegir

16th Oct 2012

There are a few write-ups about using Aegir to automate your deployment process notably one from Mig5: Zero-touch Drupal deployment with Jenkins, Aegir, Git, Fabric and Drush. I recently wanted to set this up for our own project, but felt like I could make some improvements.

I don’t like deploying branches, because it can be really hard to actually find out what was deployed at a later date, and you can’t reliably re-deploy that previous code later on. I think it’s much better to deploy tags. It also gives you an easy way to flag when you do want to...

Read more

Puppet and Vagrant dream team

17th Aug 2012

Sorry if you are expecting the 'solution' to be given in this post, but this is basically a brain-dump of where I'm at with this problem, and my thoughts on how I might go about solving it.

Background

First up, a little background on Computerminds and the sort of development we do. We tend to take on a mixture of projects, we have projects where we'll be completely responsible for the entire technology stack, and others where we need to bootstrap a team of developers internal to the client and set them up with a stack capable of running...

Read more

Guard livereload

1st May 2012

Livereload is one the coolest things to happen to frontend development in the last little while, and actually it can really speed up your work. Basically it re-loads your CSS (and Javascript some of the time) automatically as you make changes. You don't have to make a change and then switch to your browser and manually reload the entire page, change 'notifications' are pushed to the browser where they will trigger that single changed file to be reloaded.

There are lots of sites detailing how it works, and there's a great Mac program called: LiveReload that will get you up...

Read more

Dnsmasq

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:


project-name.drupal

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:


127.0.0.1      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.

Installation...

Read more

Making the Flag Module's Confirmation form use AJAX

Chris Didcote
Chris Didcote
17th Apr 2012

This article discusses how we can use a combination of techniques to take the standard 'Confirmation Form' provided by the [Flag][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

Chris Didcote
Chris Didcote
8th 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][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

Custom add another

6th Mar 2012

Drupal 7 fields are great, but using multiple valued fields and [field collection][fc] you can quickly reach the point of having a form that looks like this:

A complex field collection form

In this contrived example I've got two field collections and a multi-valued 'Links' field within that.

Although it's reasonably clear what clicking 'Add another item' will do in each case, when the form is full of data it can become less so.

We can give content editors a helping hand by changing the buttons from 'Add another item', to something more useful like 'Add another carousel item' etc...

Read more

Add stuff to a node and configure it like fields

28th Feb 2012

UPDATE: The Extra Field and Extra Field Settings Provider modules facilitate doing this sort of thing in Drupal 8. Read on for older Drupal sites, and for the concepts behind this.

We often want to add things to the content of a node or any other entity in Drupal 7 using hook_node_view(), hook_node_view_alter() or a similar hook in a custom module. This could be anything from a custom social media link, a field rendered in a custom way, additional author information or virtually anything else.

The rendered node with our pseudo-field

Here's the code used to add that Facebook like button:


/**
 * Implements...
Read more

Quick tips: Adding an empty master branch

21st Feb 2012

When I create a git repository for a new project on Drupal.org I don't bother to create a master branch, branches named 6.x-1.x or 7.x-1.x have special meanings and are the ones that we're encouraged to use. However, drupal.org doesn't allow us to [change the default branch][branch-issue] on d.o itself, so even though there may be no branch called 'master', it's still the default branch, so sometimes cloning a repo will fail:


git clone http://git.drupal.org/sandbox/darthsteven/1268648.git
Cloning into 1268648...
remote: Counting objects: 177, done.
remote: Compressing objects: 100% (176/176), done.
remote: Total 177 (delta 103), reused 0 (delta 0)
Receiving objects...

Read more