Mar 122013

If you regularly use Features to deploy a site from dev to staging to production, you’ve probably come up against a problem with file fields not behaving themselves when you add them to Features. This problem is particularly bad with taxonomy terms that have an image field, which are commonly put into Features as part of the site structure rather than client-entered data.

GUFF (Generic UUID file fields) solves this problem by providing an automated system to encode managed files (eg, file fields) into .php include files that are handled through the standard Features system, and can be put into version control.

GUFF works with UUID files, and once enabled it should Just Work. Has saved us a lot of pain.

Feb 142013

Sometimes you don’t want all those numbers on your pager. Or you don’t want the text ‘next’ etc. It is very easy to change those in a preprocess. This code changes the number of pages shown in the pager from the default down to 5, and changes the first, next, previous, last text to arrows.

function yourtheme_preprocess_pager(&$variables, $hook) {
  if ($variables['quantity'] > 5) $variables['quantity'] = 5;
  $variables['tags'][0] = '<<';
  $variables['tags'][1] = '<';
  $variables['tags'][3] = '>';
  $variables['tags'][4] = '>>';

Add this to your theme’s template.php and replace ‘yourtheme’ with your theme’s name.

Jan 222013

Every now and again, someone in IRC wants to know how to completely remove javascript from Drupal 7. This isn’t necessarily a good idea – there’s a lot of little things in Drupal that use javascript, and you really don’t want to remove javascript from the admin side of the site as it won’t be anywhere as easy to use. However if you are quite sure that you really, really do want to remove javascript, you need the following code in your theme’s template.php.

function yourtheme_js_alter(&$javascript) {
    $javascript = array();
function yourtheme_html_tag($variables){
    $element = $variables['element'];
    if ($element['#tag'] == 'script') return "";
    return theme_html_tag($variables);

Make sure you change “yourtheme” to the name of your theme. Clear cache, and you’ll have no javascript. Note that this completely removes *all* javascript including the default jquery from all pages, and if you want to remove it only from select pages you’ll need to wrap the code in conditionals.