Drupal 7

Drupal 7: Update Field Definitions For Lists

17th November 2016

I had to update a Drupal 7 site recently and needed to change the field keys of a list field to be different values. This wasn't possible from within Drupal as it does a pre-check to make sure that the key doesn't already exist. If it finds any values present in the database with that key then it will reject the change. This is absolutely correct but causes a little bit of an issue when you need to update these values.

Overriding Drupal 7 Theme Functions In Module Files

16th December 2015

When overriding theme functions in Drupal 7 you would normally copy the theme function into the template.php and alter it to suit your needs. This isn't always convenient though, especially if you are trying to abstract functionality into modules and not have code in your theme layer that is reliant on module code. If you add theme override functions to your module files then they won't do anything as Drupal isn't looking for them there and won't pick them up.

Drupal 7 File Stream Wrapper Translation

18th October 2013

Steam wrappers were introduced in Drupal 7 and allow user file locations to be kept in a maintainable way, although I often forget which function to use to translate them. The three wrappers available are public://, private://, and temporary://, which map to the public, private, and temporary files directories respectively. All user files in Drupal are stored in either of these directories and they are referenced in the database as the file wrapper followed by the location of the file.

Testing Multi Step Forms In Drupal 7

I am currently using SimpleTest to test a complex multi-step form implementation in Drupal 7. It made sense to do it this way as there are a lot of factors involved that all need to be accounted for and automating what form elements appeared on what page was the most robust solution. In order to test how the form worked I needed to submit to the form once (using a $this->drupalPost() method) and then submit the form again using the same method. The tricky bit here was that when calling the drupalPost() method with a URL it first called drupalGet() on the URL before posting to the form.

philipnorton42 Thu, 06/14/2012 - 09:12
Loading A User's Groups In Drupal 7

Whilst working with Organic Groups today I had the need to load a list of the nodes that a user is connected to. After a bit of looking around in the source code I couldn't find a good solution on how to do this. So after looking around on Google for a bit I just sat down and wrote one.

philipnorton42 Tue, 05/22/2012 - 16:50

Drupal 7 Expanded Menu Control On Nodes

1st December 2011

I recently noticed a strange little issue with Drupal 7 that seemed like either an oversight or a decision I don't agree with. Essentially, when a node is created with a menu item in place the extended flag on the menu will not be set, but the control is also not available on the menu admin page. This means that when you are trying to print out a hierarchical menu structure you need to create the page, go into the menu admin area, access the menu, click on edit to access the menu item and change the setting there.

Drupal 7 Queues API

The Drupal 7 Queues API is a few feature of Drupal and provides a first in first out data structure that is used internally by Drupal itself and can be completely customised.

The Queues API isn't just a part of the codebase of Drupal, it is used internally as part of several different processes. The Batch API, which allows lots of things to be done at once, is built upon the Queues API and provides some customised queue classes. I won't be going into the batch API in this post, but I might cover it in later posts.

The new cron system in Drupal 7 uses the Queues API heavily. It works by allowing other modules to create queue items during their normal hook_cron() calls, which are then run afterwards. Each module that wants to include an item in the system cron queue can do so by implementing a hook called hook_cron_queue_info(), which tells cron what function to callback when the queue items are retrieved.

philipnorton42 Wed, 06/15/2011 - 08:52
5 New Things In Drupal 7

A couple of weeks ago saw the release of Drupal 7 so I thought I would run through a few new features that might be of interest. This certainly isn't a comprehensive list of new things as there is a lot of changes in this new version.

philipnorton42 Thu, 01/20/2011 - 09:47