Articles about Modules

Excluding common requests from your apache logs

Log files can get filled up with repeated calls to files such as favicon, robots.txt, images, css js etc
This can be a pain when you need to scan the logs for issues and they are full of unimportant requests.
This is especially so if you use Ultimate Cron in Drupal and run cron every minute - the logs get swamped with the cron calls.
Mostly you want to log the initial request for a page and not all of the resources subsequently requested.
Troubleshooting other issues may mean you would log files such as favicon, images etc - but generally they needlessly fill up your logs.

Move your body (from views to Display suite)

Lately I find myself more and more moving from views fields to using Display suite layouts. However one bit of functionality I love about views is its text trimming and striping.
What I like to do is create a display suite code field that lets you do this using the original views function. I also try and keep my code in a unit and call it from the display suite (so its not hiding in the DB).

Drupal 7 menus in a localized site

i18n / Internationalization module

We use the i18n menu module that comes with the Internationalization module.
While the module provides configuration options for language specific menu items, simply enabling the module creates a new translation text group called "Menu" that exposes all menu items to the translation interface.

You can use the translate interface to translate all the menu items except for once created by nodes for those you should translate the node and specify the translated menu title.

How to let users create 'unpublished' content in Drupal 6

Basic Content authoring in Drupal

Each node in Drupal has an option to be 'Published' or 'Unpublished Published' under “Publishing Options” in the node edit screen. This enables content authors to be able to create content before publishing it on the live site. The field out of the "core" box can have the values of published and unpublished (this can be extended but that's a topic for another post).

Doing it the Drupal way...

It is quite common practice to add head elements such as:

  • metatags and links such as webfont links and
  • xmlns namespaces

as text to the html.tpl.php or in template.php in hook_preprocess_html etc and other string based ways of doing things.
The problem with this is that it is hard coded and not the Drupal way. I have cobbled together some examples of how we do this in code (most of which have been gleaned from issue queues, posts and other great sources - credit to many anon contributors! The point here is simply to pull together some examples.

Drupal_add_js - Tip: Checking for javascript already added to page

We are working on a series of Facebook modules for Drupal at the moment. These enable us to use Drupal to serve facebook applications and integrate the site(s) we are developing tightly with Facebook. We are developing them as a set of submodules (more on that later...)
One of the issues we have faced is that javascript needed for opengraph integration may be added by more than one module (custom and contrib).
Using drupal_add_js() in several modules.

Drupal Commerce Order display - Missing Template filename and path - .tpl.php

Wrestling with an error message on a Drupal Commerce site today. I kept getting errors relating to a missing template file with no path and no file name .tpl.php. Fortunatley with a little debugging giving me a pointer to the correct issue queue on Drupal the solution was readily available. So here's a few easy steps to follow in case you have the same issue.

History of Parliament Online

We were engaged by the History of Parliament Trust to work on their flagship website that publishes the results of research into the members and constituencies of all British parliaments since 1386. This data rich web site is managed by the Drupal CMS and has tens of thousands of 'nodes'. We were tasked with solving various issues with the site's performance and importing data from the DTP files used to create the published volumes.

Drupal Blueprint theme playing SEO nicely with other modules

Getting your page title and metatags correct is great for SEO and enables your readers to locate your content by getting it indexed well.
In this post we'll see how to get your modules and theme to play nicley together to ensure that your page structure is optimal for web standards and indexing. In most cases this can be sorted with a simple fix.

Drupal Ubercart - Changing your 'cart' to your 'basket'

If you use the Ubercart module suite for Drupal to create e-commerce sites (we do and love it!) then one of the things you may wish to do is to change the default 'cart' to 'basket' - for a non-US audience. There is no setting in the Ubercart modules to enable this - but it is really easy and here's how to do it.
Get the excellant string overrides module and install it. Then set it up to swap the following fields:

Working with large (Drupal) taxonomies

Drupal is great and the taxonomy system is great - but large taxonomies (over 1,000 terms are a headache for any system) and Drupal is no different. I have a new taxonomy for a project with > 5k terms in a three deep hierarchy and using it presents some usability, performance and other issues.
So I though I would take a break and write a bit about evaluating some Drupal contributed modules for working with large taxonomies:

handling 404 errors on hosted CMS

A general housekeeping task for CMS systems such as Wordpress and Drupal and other websites and good practice to keep your site SEO high is to make sure you are gracefully handling missing pages (404 errors).
One of the routine tasks to carryout is checking for crawl errors in Google Webmaster tools. If you see any missing pages in the list it is worth making sure you have some measures in place to handle these and ideally issue a 301 redirect so that Google and other search engines update their indexes.

Technology Articles

Update: we have now combined this site with our main site! And all the articles are available in the one site.

We wanted to create a home for our knowledgebase and created the website Here we provide a range of articles and posts covering issues from using CMS systems such as Drupal through to security articles covering securing access to your website.

Trouble shooting Cron?

It ducked!
Monday morning the sun is shining and your email box is full of emails saying cron is failing on one of your sites.
In this post I will look at what is going on, how you can troubleshoot it and fix it and how life may be made easier in the future by a) adding a bit of logging to cron and b) features in Drupal 7.

Module Weights

Some modules use the same hook and therefore are 'called' in succession. Sometimes you would like (need) a particular module to fire after or before other modules. An example is the XML site map module that would best fire after the pathauto module to ensure that the site map contains the final version of the urls used for pages in your site. There are a number of ways to manage this -

Your First User, Permissions and Roles

When you first install Drupal it creates the master user (1) - this should ideally not be used to create content and it is good practice to create a new user for administrative purposes (not called admin but with an equivalent set of permissions) and an administrators group so that the super user doesn't get used - it may even be worth blocking the super user once you have done that. But be aware that some modules need to impersonate that user. If you want to restrict login for that user you can create an Access Rule to deny Admin for user name - this will effectively disallow logging in as Admin.

Path Rewriting and changes to Path Auto

Quick note: On a site I worked on recently I made a change to the Pathauto settings and needed to create a load of Redirects for previous URLs. Fortunately there is a quick way to do this using wildcards in the htaccess.

Gotcha: Displaying the search box on a new Drupal Site

One of the most frequently asked questions for a new Drupal installation is - How do I get the search box to show? The answer is go to Modules and locate the search module in the core modules and enable it - it is disabled by default. Another gotcha here is checking your permissions and ensuring that users have access to search and other facilities.

See your first user permissions and roles

Drupal Post Images and Thumbnails

To be able to add an image field to a content node that will be displayed in the node and as a thumbnail in the listings.

See for a good tutorial

The tutorial covers it well but is for 5.x so the following updates are required to do it in 6.x.

Some of the functionality will be in the core of 7.x.