Drupal

Posts about Drupal, the open source content management system.

Drupal Logo

Drupal 6 Form Elements Example Module

21st September 2011 - 8 minutes read time

During my work developing Drupal sites I am quite often asked if I can provide a example of form elements for designers. This is so that they can test their designs with all possible form elements that might appear in a Drupal install and make sure that the theme we create will be robust and future proof. I often find myself forgetting how to create, say, a multi select element and needed a sort of cheat sheet that I could look form elements up on.

To this end I sat down and created a list of all of the Drupal form elements and packaged them into a module so that when the path 'form_elements' is loaded a very large form with lots of elements will be rendered. There is even a tabledrag form component in there, which is used quite a bit within the Drupal administration pages.

Drupal Logo

Remove Input Formats Help In Drupal 6

30th August 2011 - 2 minutes read time

The input format help text is a good way of telling your users about the sort of content that they can enter into any text area. For some users, however, they can get in the way a little and even cause confusion, especially when WYISYG editors are used as much of the help text will be quite useless to most users.

The input format section is controlled by the Filter module, which is built into Drupal core, and it comes with a couple of handy hooks that allow control over this section. The filter tips section is split into two parts, the actual filter tips text itself and the more info link below the tips. If you want to remove these then just pop the following into your theme template.php file and change the function names accordingly.

Drupal Logo

Drupal 7: Login Destination Based On User Role

19th August 2011 - 3 minutes read time

The Login Destination module is a neat little module that allows site admins to customize where the user will be sent to when they login. It provides a few of different ways of customizing, including a PHP snippet box that allows fine grained control.

What I needed to do on a recent project was to change the login destination for a single user role, but redirect everyone else to their user profile page. This required the use of the PHP snippet box. In order to get access to the current user object I had to include it into the scope of the PHP snippet code by using the following.

Drupal Logo

Drupal 7 Queues API

15th June 2011 - 26 minutes read time

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.

Drupal Logo

Drupal7Camp Leeds 2011: A Review

25th May 2011 - 25 minutes read time

This weekend I attended the Druapl7Camp 2011 in Leeds and so I booked a hotel room for the weekend and managed to find the right place on Saturday morning. I was one of the first to arrive and was able to greet people as the came through the door. With coffee flowing nicely and the wifi appearing to be stable we all set down to the first session.

Image removed.
Photo By Richard Burford

Day 1

Install Party/Webfaction Demo
Steve Cowie

Drupal Logo

Drupal7Camp Leeds 2011 This Weekend

17th May 2011 - 2 minutes read time

ImageThis weekend (21st-22nd May) will be the Drupal7Camp 2011 in Leeds and I have organised myself tickets and hotel to attend. Drupal7Camp is a barcamp that is devoted Drupal 7, and so will consist of talks and sessions from the attendees. As a result the actual sessions list will not be decided until the day and will also consist of some informal discussions and workshops.

I will be representing #! code at the event (probably with my #! code t-shirt) and will be giving a session on the use of the new queues functionality in Drupal 7.

Drupal Logo

Drupal 6 Upload Module Reference Warnings

16th May 2011 - 4 minutes read time

I was testing out a new Drupal project build and found this strange error when uploading files to nodes using the Upload module. This error produced a lot of warning messages that appeared on the screen (in the process alarming my project manager) but appeared to have no impact on the actual function of the module, or the file uploaded. Essentially, when a file was uploaded the following errors were produced.

Drupal Logo

Creating Custom Views Filters With An Exposed Form Element In Drupal 6

20th April 2011 - 5 minutes read time

Views is an amazing module, but sometimes you can come across certain limitations that make life difficult. For example, I created a view that pulled in a bunch of nodes based on different taxonomy terms. The problem was that I had more than one taxonomy term in different vocabularies being used to filter the results, which essentially caused the same field in the term_data table to be used for both taxonomy filters. So, no matter what I changed the parameters to I always received no results. I did try and add the second term as an argument but it isn't possible to do LIKE matches with views arguments.

Drupal Logo

Automatically Copying The Node Title To The Menu Title In Drupal 6

13th April 2011 - 3 minutes read time

One new feature of Drupal 7 is that any title you give a node will be copied to the menu title field when you create a menu item. I wanted to replicate this functionality in Drupal 6 and so I created a function that did just that. I have used this function a few times in different projects so I'm posting it here.

This code uses the drupal_add_js() function to push a small amount of JavaScript code into the page when a node is added or edited. The hook hook_init() is used to add this content as it is run very early on in the Drupal boot cycle. I have tried putting this code into other hooks (like hook_preprocess_page()) but it isn't included, I would look into this further but this solution seems to work well.

Drupal Logo

Overriding Drupal 6 Automatic Select Element Validation

29th March 2011 - 9 minutes read time

Whilst creating a large and complex form in Drupal 6 recently I hit upon a problem that took me a couple of hours to solve so I am posting the solution here in case anyone else gets similarly stuck. I am also writing this down so that I can remember the strategy in case I have to do the same thing again.

What I was doing was creating an event booking form. The form allowed users to select from a number of times slots in a select list, but each time had a limited number of bookings. When the user submitted the form and all allocated slots for their selected time were fully booked they were shown a message asking them to select a different time slot. The original time was removed from the select list so that the user didn't try to select it again. This was fine and it all worked as expected but when this happened I also got the following error message from Drupal.