Drupal

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.

Enabling The Use Of delay() In Pre jQuery 1.4

The other day I was trying to convert a HTML template into a CMS system and I found a stumbling block with the use of the jQuery function delay() in the template's JavaScript. During part of the templating process I found the following error occurring on the page.

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.

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 6: Change Views Exposed Filter Form Select Element To A List Of Checkboxes

Whilst creating a view for a Drupal site the other day I created an exposed form but rather than the usual select boxes that get displayed I needed them to be a list of check boxes. Whilst searching about on Google I eventually found this article, which kindly provides a function that will do this. Here is the function in full.

Null Response From Drupal 6

I recently had some trouble with a Drupal 6 site I was updating. I wanted to create a local working copy of the site to test so I downloaded the files and backed up the database, but for some reason I couldn't get the site to run. In every browser I tried I would get "page cannot be displayed" or "host unresponsive". These messages were basically telling me that something on the site was causing it to fall over before it ever got around to producing any HTML, and so the browsers were treating it as best they could. I tried clearing the Drupal cache and disabling some modules but this didn't appear to do anything, or simply broke the site. Searching the internet for this problem yielded very few results, so I eventually had to track the problem down myself.