planet Drupal

(Submitted Thu, 2009-07-30 20:37)

Here's a quickie. Automatically disable comments on posts older than a given timeframe. I find that comments on posts older than a few months are generally spam.

Plug this into your site's custom module. As usual, I am using the convention of 'mymodule' for the namespace, and you'll want to replace this with the name of your actual module.

<?php
function mymodule_cron() {
 
$time_ago = strtotime("-4 month");
 
$result = db_query("UPDATE {node} SET comment=1 WHERE created < %d AND type='story' AND comment=2", $time_ago);
}
?>

Exercises for the reader: you could also make a settings page to make the "time ago" configurable (currently I have mine hard-coded to 4 months) and the node types to which it applies configurable (currently I have mine hard-coded to 'story' nodes)

(Submitted Fri, 2009-07-24 21:13)

I generally get called on to projects to do custom module development and internal architecture/engineering, so I have increasingly less frequent contact with the front end tools and site building type modules. But I've been playing with Panels again lately for a project and ran into an issue with block visibility. While Panels will generally give you an option to respect a block's configured visibility settings, for blocks generated via Views, it does not (even if you have specified visibility rules for that block via admin/build/block). I suspect this is because Panels invokes Views generated blocks directly thereby bypassing that extra 'layer'.

Read on for one solution to this problem.

(Submitted Fri, 2008-12-19 03:24)

Today John Resig of jQuery fame released the FireUnit extension, which provides a method for unit testing javascript, integrated with Firebug. Seeing as how jQuery itself has become such an integral part of most Drupal developers' work, this looks very promising.

You can read his post about it over here.

(Submitted Sun, 2008-12-14 21:14)

Recently I was contacted by an individual who I have done some Drupal work for in the past. He has an older site that is primarily static HTML with a perl script handling contact form submissions. As most of us experience once a website has become established, he was getting inundated with spam through his contact form.

He was willing - though not overly eager - to implement a CAPTCHA solution but was worried about introducing an extra hurdle for those making casual inquiries. As the various spambots were filling in all the form fields with mostly random garbage and their website links, we decided to just do a validation on the phone number textarea and reject the submission if the phone number validation failed.

Read on for a sample implementation of 'reverse CAPTCHA' aka 'negative CAPTCHA' as an extension to the existing Drupal CAPTCHA module.

Hosted By Dreamhost.com