Feb 6, 2012 - Upgrading to drupal 7

A couple of notes on this. Which should be obvious.

Don't try and do it in a lunch break. Make sure your host gives you enough memory. 32MB won't cut it. Hopefully if you are seeing this it means that I have rectified these mistakes. 

Dec 16, 2010 - Views3 "Group by"

Drupal 7 is a great improvement over 6, I can't wait for it to be released. However it's progress is eclipsing what could be an even greater improvement to the Drupal ecosystem and that is Views 3

Views is one of the most popular and most useful Drupal modules. Views 2 allows a huge amount of flexibility. Views 3 takes this to an almost unbelievable level.

However the documentation is still catching up. One of the features which has been added is support for SQL group by clauses.

The feature was added in "Enhance Views to support proper GROUP BY queries" if you read the thread all the way through and the code you can get an idea what is going on. Or you can read the rest of this post, which should explain it much more quickly.

When you create your view one of the options in the "Advanced Settings" is "Use Grouping", you can edit this to change the view to use grouping.

WARNING unlike most other options in views, the use grouping option is not overridable, that is it will affect every display in a view. This is often not what you want, so you may have to clone an existing view before you do this.

Once you have done this your fields will have an options cog next to them, this allows you to select the grouping options.

Group results together is a standard Group By clause, Others are also standard sql aggregate functions, obviously you should be careful not to use them for fields types which make no sense. Average on a string will throw an error.

You can also use these grouping functions for sorting and for filters. Which uses the SQL HAVING clause.

Once you have tried this a little I am sure you will get the hang of it. If you are used to the Views UI there is very little extra to learn.

Aug 23, 2010 - Drupal 7 libraries

I have been working on Drupal 7 sites for a while now, mostly on research projects. I like a lot of the D7 features, and think it is a big step forward over Drupal 6, which wasn't bad to begin with. Most of my work on D7 won’t have modules which will go on Drupal.org, being 'closed' or at least too specific. So I was pleasantly surprised when I was working on a side project to see an opportunity to give a little code back.

Drupal 7 allows modules to define libraries, this solves a few problems which have existed. It allows new libraries to be added and shared easily and defines dependencies between libraries. All in all it is a very nice little addition, and makes life a lot easier than working out which js and css need to be added to get particular feature working.

I was working on something which was using the google data and visualisation libraries. It was easy enough to add some code inline to include these libraries. But as you need to add a domain specific api key this would make the code a little nasty unless I put in a configuration page.

When I got to that point, I realised that there may be several modules which would require the same key, so clicked that this could be a good use for libraries. So I created the google api libraries module.

It is not rocket science and indeed it could be improved to make use of dynamic or auto loading, but for the moment it serves a purpose.

I think as Drupal 7 matures there will be many more modules which provide common libraries. The difficulty will be standardizing them. I would like to see some discussion about naming conventions for such libraries and a little checking that where a library is available a module uses it rather than including files directly.

It may be possible to create a meta library, which module developers can use to see if a particular file is included, certainly the structure of hook_library() lends itself to creating searchable data. Maybe something for the future...