Drupal Planet

Configuring the Reroute Email module

Reroute Email module uses hook_mail_alter() to prevent emails from being sent to users from non-production sites. It allows you to enter one or more email addresses that will receive the emails instead of delivering them to the original user.

Include a local Drupal settings file for environment configuration and overrides

At the bottom of settings.php, add the following code:

$local_settings = __DIR__ . '/settings.local.php';
if (file_exists($local_settings)) {
  include $local_settings;

This allows for you to create a new file called settings.local.php within a sites/* directory (the same place as settings.php), and this will be included as an extension of settings.php. You can see the same technique being used within Drupal 8's default.settings.php file.

Include environment-specific settings files on Pantheon

I was recently doing some work on a site hosted on Pantheon and came across an issue, for which part of the suggested fix was to ensure that the $base_url variable was explicitly defined within settings.php (this is also best practice on all Drupal sites).

The way that was recommended was by using a switch() function based on Pantheon's environment variable. For example:

Include CSS Fonts by Using a SASS each Loop

Using a file structure similar to this, organise your font files into directories, using the the font name for both the directory name and for the file names.

Updating Features and Adding Components Using Drush

If you use the Features module to manage your Drupal configuration, it can be time consuming to update features through the UI, especially if you are working on a remote server and need to keep downloading and uploading files.

git format-patch is your Friend

The Problem

As an active contributor to the Drupal project, I spend a lot of time working with other peoples’ modules and themes, and occassionally have to fix a bug or add some new functionality.

In the Drupal community, we use a patch based workflow where any changes that I make get exported to a file detailing the differences. The patch file (*.patch) is attached to an item in an issue queue on Drupal.org, applied by the maintainer to their local copy of the code and reviewed, and hopefully committed.

Download Different Versions of Drupal with Drush

How to download different versions of Drupal core using Drush.

Quickly Apply Patches Using Git and curl or wget

How to quickly download a patch file and apply it to a Git repository in one line.

Don’t Bootstrap Drupal, Use Drush

There are times when doing Drupal development when you need to run a custom PHP script, maybe moving data from one field to another, that doesn't warrant the time and effort to create a custom module. In this scenario, it would be quicker to write a .php script and bootstrap Drupal to gain access to functions like node_load() and db_query().

To bootstrap Drupal, you would need to add some additional lines of code to the stop of your script. Something like:

Create a Zen Sub-theme Using Drush

How to quickly create a Zen sub-theme using Drush.


Subscribe to Drupal Planet