Data.gov.uk

I've recently been working on a very exciting project - building the Drupal front end of http://data.gov.uk/

It's great to be working on another opendata project using Drupal - and again working with really smart people committed to opening up data.

This is big project with real ambition - and I go to meetings where I get to  learn stuff :-)

Read more

Drupal Module for CKAN Integration

Here's a basic Drupal Module that pulls CKAN data into Drupal.

It provides a simple search interface - when the user views a CKAN package for the first time a corresponding node is created.

When this node is then viewed Drupal loads the package details - I'm only displaying notes and title here as I've run out of time tonight - but the rest of the data is there.

You can then have user comments, voting, etc on these pages.

Read more

Accessing CKAN data from PHP

I've been working on a couple of open data projects recently - which has been very rewarding.

A couple of people have asked for some code so I've knocked up a quick version of the sort of thing I've been working on.

This code requires PHP 5.1 for the JSON functions but doesn't need any extra libraries (pecl_http can give better error messages but is a bit of a pain to install).

The Notes field in packages returns output in Markdown format - you can convert this to HTMl with a parser available at http://michelf.com/projects/php-markdown

Read more

Drupal - the missing API

I was just reading this presentation on deploying Drupal

http://www.slideshare.net/eaton/drupal-deployment-presentation

and noticed

http://drupal.org/project/install_profile_api

Which seems to have a collection of API functions needed at install/upgrade time that are missing from Drupal (and contrib modules)

And even better this is great motivation to write more such functions myself instead of just using SQL hacks.

Read more

Drupal as URL shortener

Drupal has a couple of modules which allow you to produce your own tinyurl.com type website - complete with your own tracking etc.

This has been extended for use by the US government at http://go.usa.com/ and the code re-released to the community.

This mainly adds statistics gathering and reporting

Unfortunately the module maintainer has chosen not to integrate these changes back into the module at drupal.org - issue here : http://drupal.org/node/520588

So now the patch doesn't apply cleanly unless you checkout an old version of the module from CVS like this

Read more

Drush "tput: No value for $TERM and no -T specified"

The drush script which provides comman line acceess to drupal functionality emits an error message when run as a cron job

tput: No value for $TERM and no -T specified

# If it is not exported determine and export the number of columns.
if [ -z $COLUMNS ]; then
  export COLUMNS=$(tput cols)
fi

I presume drush uses this information to calculate layout of output.

However when running as a cron job COLUMNS is not set and tput gives the above error.

Read more

Drupal Cron getting stuck

I've just run into the drupal cron problem again  

Cron fails and the error log says

"Attempting
to re-run cron while it is already running."

 

  • delete from variable where name='cron_semaphore';
  • clear caches
  • run cron from the web page

That seems to do the trick.

Now cron runs OK fom drush or web.

Read more

Programatic Block Creation in Drupal

To remove static blocks and replace with as custom block.

Implement hook_block specifying the default visibility and so on

<?php
$blocks
['random'] = array(
     
'info' => t('Random'),
     
'weight' => 0,
     
'status' => 1,
     
'region' => 'sidebar',
     
'pages'  => 'offers',
     
'visibility' => 0, // all pages except
     
'cache' => BLOCK_CACHE_PER_PAGE,
    );
?>

Create an update hook that deletes the old blocks and boxes (I've specified the ID as I know they won't change on my site).

Read more

London Datastore

"The Mayor of London Boris Johnson today (7 January) fired the starting
gun on an information revolution in the capital as he announced that
City Hall is to release online, for the first time, huge realms of
previously unavailable data for everyone to see and use free of charge. " see full press release

 

London Datastore

http://data.london.gov.uk/

Read more

Make Drush support PHP-5.1

Drupal has a fairly easy to meet set of requirements http://drupal.org/node/502452

But Drupal projects are free to set their own rules in this area and Drush has used functions only available in PHP 5.2 - as far as I can see this is just the json functions.

Frustratingly the latest version of RedHat provides PHP 5.1 and this is the second time I've run into the problem with a client who uses RedHat and understandably wants to stick to the standard packages.

Read more