It’s difficult to get around Drupal-modules that appear to have the same functionality. This is particularly the case when you want to set-up decent SEO-friendly url’s. The two main modules are called “pathauto” (also named: url-alias) and “path-redirect” (also named: url-redirect). This post applies only to Drupal 6.


pathauto = url-alias = /admin/build/path/list = table url_alias

path-redirect = url-redirect = /admin/build/path-redirect/list = table path_redirect

PathAuto (or URL-alias)

Pathauto is the standard module that creates SEO-friendly URL’s for users, nodes, taxonomy (etc) based on the title of the node. You can set up what the url’s must look like in /admin/build/path/pathauto

But when an url gets changed, the previous url would become unreachable and the user would get a “404 – page not found”-error. This is negative for search engines, bookmarks, and links from other sites. This is where path-redirect comes to the rescue.

Path-Redirect (or URL-redirect)

The path-redirect module keeps a list of all aliases that were changes and redirects them with a 301 (the permanently moved http-status).

In order for this to work, you need to check an checkbox in path-redirect  (see screenshot). Direct link: /admin/build/path-redirect/settings

path-redirect settings for Drupal

As if that ain’t enough, you also have to specify this in PathAuto. Go to: /admin/build/path/pathauto and scroll to “General Settings” > “Update action”. Select “Create a new alias. Redirect from old alias” (see screenshot)

Instead of logging to the database, it could make more sense to log to the operating system.



  • The OS has already a great way of maintaining logs, so there isn’t really any need to have a separated database logging.
  • The options to maintain or report logs with the OS are much larger than the default Drupal database logging system.
  • Database logging eats away performance from your server, certainly when Drupal writes tons of logfiles each day.


  • Any shared hosted website can’t use this option, because they have no access to the OS’ logsystem.
  • If your website is maintained by a so called “webmaster” or a “not so technically equipped person”, it may be easier to log to the database, because nontech persons would generally prefer to access the logs through the Drupal admin interface instead of using some dodgy Unix command. Of course, you could ask yourself if a nontech person is anything with the Drupal logs in the first place.

Continue reading “Write Drupal logs to rsyslog instead of to dblog”…

This function will print a large list of all the variables that are declared in the current scope:

An interesting variable is $node, but it is not always accessible.

Once you have created a field in Drupal, the fieldname will haunt you forever. A spelling mistake will keep living, and refactoring is out of the question.

It is however possible to change a fieldname in Drupal 6, but it might cost you a couple of hours work and a hard focus.


Drupal stores the fieldname in every thinkable place:

  • column-names
  • table-names
  • row-values

The obvious content-field-tables are an easy task, you can even do that manually. But Drupal also stores the fieldname in many other not-so-evident places, in views for example where fieldnames are stored as serialized data.

An all working script to change the fieldname is not evident (a reason why the possibility is not included by default in Drupal). There is a module that did an approach to change a fieldname, but in my option it’s best to do it all manually with a checklist.

Step by step guide

I made a step by step guide about how to change the machine name of a Drupal-6 field.

1) Backup

Backup your entire database. Test this script on your local machine or on a dev-server, not in a live environment. There is no guarantee that it won’t break your database.

2) Automatic script to change evident table names and column names

I made a php-script to make the task easier.

The script:

  • changes the fieldname in the most common places in the database.

Continue reading “How to change the machine name of a content field in Drupal6″…

I wanted to make a list of “related nodes” based on the term that is attached to the node.

Say I have 10 nodes that have the term “fruit”. With every fruit-node I want to display 5 links to other fruit-nodes.

I work with panels and views.

This turned out more time-consuming then I thought because the way to do it is not straight forward.

  1. Make a new view
  2. Add “taxonomy term id” as argument. Select “hide view” is the argument isn’t provided.
  3. Add a couple of fields to display (eg: title, teaser).
  4. Save the view. Make sure your caches are cleared.
  5. Make or edit a page (with the panels module through: Administer › Site building › Pages).
  6. Make or edit a variant.
  7. We need to add a new relationship to the variant. This will make it possible to parse the term id  to the view.
    1. Click on the tab “context” in the variant.
    2. Add a relationship. Select  “Term from node” in the dropdown and click the “Add relationship” button.
    3. A new window will open. Select the correct vocabulary (in my example: the vocabulary where “fruit” belongs to). You might want to give it a decent name so you can recognise it later.
    4. Click “ok”.
  8. In the “content” tab, add a new pane to the panel. (click the gear icon and select “add content”)
  9. Select the view you’ve just created (under the “views” tab on the right) and select the “default” view. (do not make a “content pane” in the view because this does not work that way).
  10. Normally it will show the views’ argument (term id) with a dropdown under it. In the dropdown select the term id of the relationship we created in Step 7.
  11. Click update & save. This should do.

Our main RSS-feed at is the most requested page next to our homepage.

It seems logic, think of how many rss-readers hourly check the feed. And, think of how many cpu and RAM that consumes, certainly with a fat system like Drupal.

An RSS-feed is easy to make in PHP. All you need is one custom query and a decent library like the Universal Feed Generator to generate the XML.

Create stripped version of Drupal setup

I used the minimal code that is needed to work in the Drupal framework. So I made a blank php-file in my www-root with this code:

require_once './includes/';

This code has the security and functions of Drupal, but without the menu’s, theme’s, and a lot of module hooks. You don’t need a menu or a theme to create an RSS-feed, do you?

So I created my RSS-feed with just this in my php-file:

  • the drupal_bootstrap function
  • the Universal Feed Generator library included
  • one query with db_query()

With cache

Let’s see performance wise. This is the report of a feed generated based on a user’s blog and articles. Memcache was not cleared before execution. Stats are generated with XHProf.

Normal setupMy stripped setup
Number of function calls115.20018.400
Consumed RAM126 MB62 MB
Total execution time1.169 MS462 MS
Number of database queries3315
Query execution time137 MS80 MS

Performance wise, my solution is twice as fast.

Without cache

These stats are generated when caches were cleared.

Normal setupMy stripped setup
Number of function calls3,284,34383,330
Consumed RAM172 MB76 MB
Total execution time9,131 MS1,000 MS
Number of database queries926131
Query execution time769 MS183 MS

9x as fast. 7x less queries.

Of course, this is just for the first run, but still.

More soon. Please discuss this idea.


The short answer:

It’s not possible

The long answer:

In a simple user form it is possible to add a single on/off checkbox.

$form['thermometer_enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Show the thermometer'),
'#options' => array(0 => t("no"), 1 => t("yes")),

But, it’s not possible to provide a default value (checked/unchecked) with a single chechbox. This causes difficulties when you want to show the saved value of a user.

A simple solution is to use a “yes/no radiobutton list” instead of a single checkbox.

$form['thermometer_enabled'] = array(
'#type' => 'radios',
'#title' => t('Show the thermometer'),
'#options' => array(0 => t("no"), 1 => t("yes")),
'#default_value' => variable_get('thermometer_enabled', 0),

In this example the result is saved in the variable thermomoeter_enabled and has the default value of 0 (false).

  • Published:October 9th, 2012
  • Category:Wordpress

To follow my example. This blog used to be on, and is now on

1) Backup/restore your database

If you want the website to be on a new databases (which is not always necessary), take a backup of the entire database (phpadmin > export > to file) and restore it in the new database (phpmyadmin > import > from file).

2) Edit wp-config.php

On a local copy of the website, edit the wp-config.php to edit the database settings. Edit the constants: DB_NAME, DB_USER, DB_PASSWORD. (in case there’s a new database, of course).

Continue reading “How to move a WordPress from one domain to another?”…

  • Published:August 21st, 2012
  • Category:Drupal
  • 1 Comment

Ever wondered which module gets executed first?

By default, every module has a weight of zero. If you want a module or its hooks to be executed first, you have to give it a lower weight (eg: -5). If you want a module to be executed after the others, you have to give it a higher weight (eg: 5).

Note that some modules (like Devel) have a standard higher weight.

In Drupal 6, the only way to change the weight is through sql.

db_query("UPDATE {system} SET weight=%d WHERE name ='%s'", $your_weight, $your_module_name);

More info and a nice list of weights on

In case you’ve installed Varnish but not Pressflow (for Drupal 6), following scenario may happen:

  1. User A logs is, gets sessionid A
  2. User A changes something and loads a new page
  3. While loading the new page, a js or css-file is being downloaded from Varnish (example: /sites/default/files/js/js_79eb17289b3a88ec931b6f4bdb728282.js)
  4. The next file that is being downloaded is a jpg. This file doesn’t come from the Varnish cache and gives a new sessionid to the user (sessionid B)
  5. The requested page is being served correctly because it was requested with sessionid A. The user is unaware that he has a new sessionid because it happened during the loading of the page elements.
  6. The user clicks on another page and sends a new request with sessionid B.
  7. Drupal checks sessionid B and sees that it the session belongs to an anonymous user. Result: the user gets an “Access Denied” and is logged out.

Solution: install Pressflow. It will stop giving sessionids to the client.

(this post only applies if you have installed Varnish)

« Previous PageNext Page » clearPaper by Copyright © 2012-2019 Robin Brackez. All rights reserved. By visiting this site you agree to accept cookies that are purely used to check how many visitors I have. Theme by: creativebits. Custom adaptations by Robin Brackez.