Drupal

Spamicide for Drupal

"The purpose of Spamicide is to prevent spam submission to any form on your Drupal web site. Spamicide adds an input field to each form then hides it with css, when spam bots fill in the field the form is discarded. The field, and matching .css file, are named in such a way as to not let on that it is a spam defeating device, and can be set by admins to almost anything they like(machine readable please). If logging is set, the log will show if and when a particular form has been compromised, and the admin can change the form's field name (and corresponding .css file) to something else."

Regular calls to Drupal cron.php scripts on a server with a number of Drupal sites

Calling the cron.php of a Drupal site is fairly easy. You just have to put something similiar into your server's /etc/crontab:
0 * * * * www-data test -x /usr/bin/wget && /usr/bin/wget --bind-address 127.0.0.1 -t 1 "http://example.com/cron.php"
Or you can place this wget call in a file in /etc/cron.hourly.

However on a server with quite some Drupal sites (and possibly a number of virtualhosts) the maintenance of these cron.php calls in your crontab becomes very annoying (and it is prone to errors). On a busy development server Drupal sites come and go every day. So why not do these calls automatically? The attached script does just that. Smiling

Drupal + Taxonomy + Tagging + automatic references in nodes

I just had an idea. I know: what a rarity! Eye-wink
It'd be nice if the field API of the coming Drupal release (v7) would support adding fields to taxonomy. I'll explain why ...

Small glitch with upgrading to new CCK in Drupal 6

I had a small problem with upgrading the CCK module during the transition from Drupal 5 to Drupal 6. I use the Link module to have a link field (the field name is "url") in a custom content type (named "link"). However after the upgrade whenever I added or updated a node of this content type, the value of the url field was empty. In the Drupal log I saw errors like this:
Column 'field_url_title' cannot be null query: INSERT INTO content_type_link (vid, nid, field_url_url, field_url_title, field_url_attributes, field_link_value) VALUES (4440, 4439, 'http://example.com/', NULL, 'N;', '<a href=\"http://example.com//\">Some link</a>') in /var/www/mysite/sites/all/modules/cck/content.module on line 1200.

Picasa Web Albums random photo block in Drupal

There's already a picasa module for Drupal, but if you just want a random photo block and not the complete integration stuff (custom node type and nodes for all the photos), then you might find my module more attractive. Its use is pretty straightforward, set up the block as you'd do with any other block. The Picasa Web Albums user id can be specified in the blocks configuration page (along with a couple of other options).

Apache's mod_rewrite and REQUEST_FILENAME conditions

It can be a little bit tricky (or at least I've not found a clear description on this topic in the Apache docs) to tell where the mod_rewrite module of Apache 2.2.x is going to look for a file if you use a condition. I've had a hard time to get this clear and maybe sharing my experience will benefit others.

Duplicate title tags reported by Google for a Drupal site

The Google Webmasters Tools reports several title issues in the "Content Analysis" section for Drupal-based sites. This due to the fact that the Drupal paging mechanism does not alter the title of the page, thus all pages within the same content list (eg. taxonomy list or the default node listing at /node or any pageable views) share the same title. You can of course alter your code if you consider this an issue as well. You could eg. create a custom module, hook into the page rendering mechanism somewhere really at the end of the process (and also set your module's weight to some huge value) and overwrite the title of the page (eg. by adding some "(page #k of n)" text to the end of the title) if the pager is being used.

How to create a new revision from a set of nodes in Drupal

Let's assume you want to mass-update a set of nodes or create a new revision for each of them. You could do this through the UI, but of course for hundreds (or thousands) of nodes this is not really an option. You can do this programatically with a small PHP script.

How to change the starting offset of a view's resultset

Let's suppose that you want to split a node list into multiple blocks (ie. views). Eg. you might want to display a few nodes as teasers and the rest as title lists. The answer comes from drupal.org's support forum. You can restrict the view's listing to a subset by specifying a starting offset in the argument handling code. Eg.:
  $offset = 5;

Node access control in Drupal 5

Access rights for all node types come from the node_access function in the node module. Unfortunately this does not give modules full control on the node types' access permissions, especially on the types provided by the node module itself ("story", "page", and all custom types created in "Administer" / "Content management" / "Content types" / "Add content type").

Syndicate content