Drupal articles

Another case of Drupal's sensitivity

25th Mar 2009

If you have a Drupal site with users and you want to allow them to add some profile data about themselves there are a few routes available to you, one of the oldest (and thus simplest) ways is to use profile module. You can add text fields, selects and other bits and bobs to users, with different visibility settings for each field. You also have the chance (in fact it is required that you do) to categorise your fields. These categories then show up as secondary tabs on the user edit page. But what happens when you want to make...

Read more

DrupalCon DC - Business Analytics in Drupal with Views

12th Mar 2009

One of the interesting sessions that I attended at DrupalCon DC was one entitled: Business Analytics in Drupal with Views. In it, the presenters showcased two of their modules. One was a charts display plugin for views, and one was a 'group by' views field.

Views charts

This was a simple module to take the output of a views query and pump it into a flash charting framework. Being able to display the output of your views with charts is really nothing new, and the presenters admitted to duplicating existing modules. Hopefully a module will emerge from the mess...

Read more

Quick Guide to using drupal_add_tabledrag and enjoying jquery drag and drop loveliness

6th Mar 2009

We are finding that the feature exciting most end users in Drupal 6 is the lovely new jquery based drag and drop, as seen on the blocks and menu edit pages - we will be quite happy never have to explain the concept of "weights" again. The best news is that you can add this functionality to your own forms for free - and here is how.

Build and theme the form

We are assuming your vaguely familiar with the form API - you can brush up here http://api.drupal.org/api/file/developer/topics/forms_api.html - so we won't go into too much detail here. Essentially...

Read more

Simple quick ubuntu 8.04 setup as LAMP (couple of drupal "specific" tweaks)

23rd Feb 2009

I'm always hunting around for these various bits every time I do an Ubuntu rebuild - so I thought I would collate them all into one place. This is what we use for our dev boxes, not certified for a production webserver. Note this is specifically for Ubuntu 8.04 - it may well apply to other versions of Ubuntu however.


sudo apt-get update

sudo apt-get install mysql-server-5.0

sudo apt-get install apache2

sudo apt-get install php5 libapache2-mod-php5

sudo apt-get install php5-mysql

sudo apt-get install php5-gd

\#enable the rewrite module for clean URLs [EDIT] thanks to Jadwigo for this

a2enmod rewrite

\#...

Read more

Altering drupal comments in hook_comment op = validate (drupal 5)

17th Feb 2009

One of those little Drupal annoyances this, there is now easy way to alter a comment (using hook_comment) before the comment is written to the DB. Hook comment is invoked during the validation phase, with $op set to "validate", and the comment array is passed by reference - but unfortunately any changes made to the comment are not passed on to the comment save function.

A quick and slightly dirty way around this is to make use of the global $form_values array and manipulate the comment directly in there - this little example will set an empty comment title to...

Read more

Views 2: Making a drupal views block title link back to the view

13th Feb 2009

We wrote an article about linking a view's block title to the companion page view, in Drupal 5. Someone asked for a Drupal 6 version, which can be quite easily done with a preprocess function, but it's not very flexible.

Instead we just need to create a new display plugin for Views 2, and that will allow us to be much more flexible in our approach.

This is my first display plugin, so it may be completely broken (though it works for me!) You'll just need to download and install the attached file like any other module.

Instead of...

Read more

Drupal 6 - Multiple instances of the same form on one page

10th Feb 2009

There's an excellent article over on gtrlabs: Drupal 5: How to process multiple instances of the same form on the same page that describes in detail how to have multiple copies of the same form on the same page. There are some subtle differences to use this technique in Drupal 6, which I'll explain below.

The idea of this technique is simple, drupal forms are identified by their 'form_id' and these ids must be unique on a page, so if you want the same form to appear more than once, you need to change the 'form_id' somehow. We do this...

Read more

Drupal node operations

7th Feb 2009

We love the views bulk operations module here at ComputerMinds, and frequently use it to create some lovely administrative interfaces.

However we often find a need for an administrator to be able to perform operations in a quick and easy way on an individual node. While some of the core operations (publish, make sticky etc) can be performed from the edit tab of the node, many other node operations do not offer this facility ("rebuild image thumbnails" for example).

So we have put together a simple module that exposes a form just like the one you get on the node...

Read more

Some nice quick views theming tricks in Drupal 5

27th Jan 2009

Thought I would post this little function on here, we tend to use it a lot and it gives some nice little extras for you to play with when you come to template your nodes.

  • $node->view_name : the name of the view this node is being rendered in
  • $node->position_in_view : the position within the view for this node

function phptemplate_views_view_nodes($view, $nodes, $type, $teasers = false, $links = true) {
  static $count;

foreach ($nodes as $n) { $node = node_load($n->nid); $node->view_name = $view->name; $node->position_in_view=$count[$view->name];

$count[$view->name]+=1;
$output .= node_view($node, $teasers, false, $links);

}
return $output;
}

Read more

Ensuring a CCK field has unique values

27th Jan 2009

Super quick one this: say you have a CCK field on a particular node whose values you want to ensure are unique across all nodes on your site, you could write yourself a nice little helper module, or some PHP directly into the CCK field validation section of the admin form, but, a helper module already exists!
Unique field is a lovely little module that allows you to say that a particular text, number or date field should have unique values across the site, or indeed in that node.

I used this on a user's profile node for a 'alias'...

Read more