code

(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 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.

(Submitted Sun, 2007-12-30 20:52)

Owing to a long development period, and several changes of the core development team, we have a lot of leftover Views that are no longer being used. However, with pages upon pages of them and quite a large site, it isn't always immediately apparent which Views are still needed and which aren't.

Here is a very small module I quickly threw together yesterday to track when Views are called/rendered and generate a report at /admin/views_audit. I doubt that there is enough general need for this to put it in contrib, but someone out there might get some use of it.

It should be just as happy running on 4.7 as 5.

Hosted By Dreamhost.com