We recently created the Stand Up To Cancer website for Channel 4. I’m going to talk about the technical challenges involved in creating a site to support a high profile, one-off broadcast like this. Unlike a TV series where problems can be ironed out as the weeks pass, there was only one chance to get… Read more »
Posts Categorized: drupal
Programmatically adding a node reference field to a type in Drupal 7
It wasn’t obvious how I could add new node reference fields to a content type. I had to work it out from node_reference_field_info() and from examining existing fields with field_info_field(). After some experimentation, this worked: “gallery_image” is the machine name of the type that will be referenced by the field – put as many in… Read more »
Useful New Bits & Pieces in Drupal 7
Everyone knows about the big changes in Drupal 7 but the details matter too, especially when they’re the kind of details that make life simpler and save time every day. Here’s some nice ones in Drupal 7. db_query No need to mess about with fetching rows any more, db_query() returns a Traversable object which can… Read more »
Drupal – number of registrations by month
Useful query – shows how many users registered on a Drupal site each month: select count(uid), month(from_unixtime(created)) as bmonth, year(from_unixtime(created)) as byear from users group by bmonth, byear order by byear, bmonth; SELECT count(uid), MONTH(FROM_UNIXTIME(created)) as bmonth, YEAR(FROM_UNIXTIME(created)) as byear FROM users GROUP BY bmonth, byear ORDER BY byear, bmonth;
Specifying the admin theme for pages in Drupal
Sometimes you want to tell Drupal to use the admin theme on pages other than the ones it decides should be under the admin theme. All you need to do is check the URL in an implementation of hook_init() e.g. function modulename_init(){ if(arg(0) == “whateverpage”){ global $custom_theme; $custom_theme = variable_get(‘admin_theme’, ’0′); } } This is… Read more »