Drupal 7

Getting Ready For The Upgrade To Drupal 9

21st May 2020
Drupal 9 will be released on June 3rd, 2020 so with this just around the corner I thought I'd put together a post about how to check if your site is ready. The transition from Drupal 7 to Drupal 8 was more of an upheaval than an upgrade. Updating a Drupal 7 site to Drupal 8 requires a lot of effort involving code changes and migration steps. Drupal 7 modules are not compatible with Drupal 8 and so any custom code written needs to be adapted to the new structure of Drupal. The difficulty of this change made the Drupal community take notice and think about how future versions of Drupal are introduced.

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.

Drupal 7: Redirect Users From Unpublished Content

9th August 2016

I was recently asked to implement a feature on a Drupal site where all nodes of a certain type would redirect to a main listing page if that node had been unpublished. The problem in doing this is that if a post is unpublished then Drupal will issue an access denied response quite early on in the boot process. When the menu item is loaded it goes through an access callback which sees that the post is unpublished and issues an access denied before anything else can happen. So in this situation you can't use things like Rules to redirect users as the rule is never triggered.

Overriding Drupal 7 Theme Functions In Module Files

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.

philipnorton42 Wed, 12/16/2015 - 10:23

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

14th June 2012

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.

Loading A User's Groups In Drupal 7

22nd May 2012

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.

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