Drupal

Posts about Drupal, the open source content management system.

Drupal Features

The Drupal Features module is a way of packaging site components with the ultimate aim of easing migration. For example, an events section in Drupal doesn't just contain a node type called events, it also contains all of the configuration settings around comments, fields added to the node type, permissions available to users, menu items created and any views used to aggregate or search the events. Features can integrate module dependencies so that all functionality that has been packaged along with the feature is available on the other system.

The main thing to realize about Features is that they are not meant to transport content, just blocks of functionality. The idea is that if you create a "blog" feature then you can package that and deploy it to multiple sites.

Filtering Node Types In Drupal 6 Search

A common practice when creating sites in Drupal is to create different node types for different purposes. Sometimes these node types can be functionality based rather than content based and are used for creating a rotating banner or something similar. A side effect of this is that you will then see these nodes appearing in search results, which can cause some confusing results to be displayed.

So how do you remove these nodes? Well with quite a simple little module you can intercept the search query and stop certain node types being searched for. Adding a couple of extra functions means that we can add form controls to the advanced search form and the search admin area so that nodes can be selected to be excluded from the search results.

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.

1 - Admin Interface
Drupal 7 comes with a nice new admin interface that has gone through lots of usability testing and redesign which has resulted in two new themes being bundled with the system. The admin interface is powered by a brand new bundled theme called Seven, the new front end theme is called Bartik. The old Garland theme is still there, but isn't enabled, so you can still use if you feel the need. Some of the older table based themes have now gone in favour of these new themes. The new Overlay module makes it easier to administer Drupal by displaying the admin pages as a layer over the current page, rather than moving the user around the site.

Drupal 6: Using Drupal SimpleTest To Test Nodes With CCK Values

SimpleTest is a great way to test your modules, but it can take a bit of setting up. For every test that is run SimpleTest effectively has a fresh install of Drupal, so if you need to test a particular function you need to have everything in place before you run the test. I was recently testing a migration module that I had written and needed to create nodes with a variety of CCK fields, which is quite common in Drupal site setups. In order to test that a CCK field saves the data for a test you need to do the following in the setUp() method, remember that this all happens before any tests are run.

Getting Started With Drupal 6 SimpleTest

Drupal SimpleTest is a module that will allow you to unit test your own modules or unit test any patches you have made for third party modules. This module will be integrated into Drupal 7, but for Drupal 6 you have to do a couple of thngs before you can start testing. This article is a very quick introduction to Drupal SimpleTest and will be followed up by more articles in the future.

The first step is to download and install the SimpleTest module as you would any other module. You can use Drush to do this if you know how.

Two Beginner Errors In Drupal 6 Simpletest

Simpletest is a Drupal module that I have been using for about a week to unit test a module I have been working on. It is a brilliant and powerful module that every module developer should be using to test their code properly. I did, however, encounter a couple of weird errors that took me a while to fix. So for the benefit of everyone else I thought I would post them here, along with the solutions. These errors are probably things that developers new to Drupal Simpletest will come across, which is why I have labelled them beginner errors.

Drupal Private File Downloads With Public Files Access Set

Drupal has two ways in which to allow users to download files, these are private and public.

With public the files are open for anyone to download and Drupal is not involved in the download process. This means that no statistics are recorded or permissions used when downloading the file. Each file is referenced by name.

Private file access means that Drupal is run every time a file is downloaded. This allows the download to be recorded and a permissions check run to make sure that the user in question is allowed to access the file. Each file is referenced by a path that can be completely different from the original filename.

Drupal hook_form_alter() On Node Form

I just spend the last few minutes looking for the solution to this so I thought that someone else might be able to benefit from it.

Calling the hook_form_alter() hook in your module using just the module name allows you to target all forms in your system, if that's the sort of thing you want to do. For a module called "My Module" this would be called mymodule_form_alter().

The power of hook_form_alter() hook is that it alos allows you to specifically target a form with a specific name within a module. A good example is if you want to alter the search form to add a class, which is a common task. To do this, create a module so that you can add the hook_form_alter() hook to it and then construct the function name in the following way:

Drupal Focus On Enterprise, London, 26 May 2010

Drupal Focus On Enterprise 2010

2010 saw the third annual Drupal Focus on Enterprise conference, which took place at the Sun Microsystems offices in London. The free event, which is sponsored by Sun, brought together a set of speakers to talk about different things that they or their businesses have done with Drupal. Even though I live in Manchester I was lucky enough to go along.

The conference consisted of two tracks, with a number of talks in each. I obviously couldn't go to every talk, but the talks I did see were of a very professional standard. The tracks weren't set in designated rooms but a head count was made of everyone who wanted to see which track and the bigger room used for the talk that got more votes.

I also arranged to meet fellow North West Drupal User Group (NWDUG) member @eli_t at the conference.

Related Items Block Using Drupal 6 Search

A related items block looks at the current content of the page and tries to present the user with a list of items that relate to the current content. Creating a related items block is quite easy, and is a good way of introducing the search module api without having to get to involved in the search module.

Before starting I should point out that there are other related items modules available. These are modules like Related Nodes or Related Items but these modules either aren't released for Drupal 6, or simply don't work in the way I wanted the block to work. I wanted a module that would act with little or no user input.