Drupal Tips and Tricks

Drupal Tips and Tricks

During development of a Drupal website, one finds many places where content can be modified and/or presented in different ways. The following is a compilation of tips and tricks related to creating a Drupal website. If you have any you wish to include here, please contact the author at alreaud@happycattech.com for inclusion into this knowledge base.

Please be aware that Drupal 6 and previous versions have reached end-of-life and are no longer supported.

AlReaud Thu, 06/09/2011 - 13:40
Tags

Two great DRUPAL modules to stop harassing spammers

Two great DRUPAL modules to stop harassing spammers

Updated: 10/10/2016

If you operate a content management systems (CMS), you're probably familiar with the curse of botnet attacks on the user registration and persistent spammers on comments. These are IP address that are attached to your CMS from China, i.e. the 163.com domain, sending regular, daily spam message updates about Viagra, Cialis, and faux haute couture, sometimes for years on end. Or they continuously try to attack the user registration CAPTCHA, trying to create accounts to do the same or worse, sometimes using inane responses to the CAPTCHA like "TooBad1" through "TooBad257", not really doing any damage but consuming sometimes scarce resources and filling up the logs (to mask other activity sometimes, like database attacks).

This is not a problem specific to any one CMS, and will happen to Drupal, Wordpress, or Joomla. Drupal, however, logs the events as part of core functionality, allowing them to be noticed by the operator. Having dealt with it for well over a year, mostly manually, I found two great modules in the Dupal repository to help curtail the intrusions and the waste of your time as operator. In my case BOFHwink

GoAway (currently Drupal 7 only)

https://www.drupal.org/project/goaway
Allows for IP banning from the spam comment view, with the miscreant IP forwarded to the URL of your choice. I've not fully experimented with the extent of the banning, however, I don't believe it's as extensive as the Add Rule ban, which is total. This should be reserved for those recursive spammers who just insist on sending you info on how to enlarge your manliness, etc…

Honeypot

https://www.drupal.org/project/honeypot
Uses honeypotting (PDF whitepaper) techniques to help prevent intrusion by botnets on comment, content, and user registration/password reset forms. This module will not stop intrusion attempts, however it will make them less effective and more cumbersome. It has good control and decreases faux comment and faux user registrations significantly on sites that have those enabled. On this site it's used for comments only, as user registration is disabled. Visitors can bang away at user registration and get access denied every time.

The implementation of both the above, along with text and image CAPTCHA and/or reCAPTCHA have allowed opening up sites to anonymous commenting while retaining tight control on user registration and authenticated user access. Well worth checking their applicability for your Drupal site if you're having the spam/fake account problem.

AlReaud Tue, 03/26/2013 - 21:17

Getting the aggregator items to go to a blank page

Getting the aggregator items to go to a blank page

The aggregator that comes default with Drupal outputs RSS links that don't open another tab or window. Sometimes it is preferable to have the links open in a new tab or window. That is accomplished by changing the called function in aggregator.module to add the tag target="_blank" to the anchor.

Open modules/aggregator/aggregator.module and change the text in function theme_aggregator_block_item to read:

function theme_aggregator_block_item($item, $feed = 0) {

    // Display the external link to the item.
    $output .= '<a href="'. check_url($item->link) .'" target="_blank">'. check_plain($item->title) ."</a>\n";

}

AlReaud Sat, 06/04/2011 - 19:18

Controlling the background color and image

Controlling the background color and image

The control for the color of the page background and the background image (if used), in the body area is in the Zen Starter Kit file css/page_backgrounds.css

Add your back-ground color or background image to the body tag at the top of the file change the default color.

body {
    background-color: #CCFF99;
}

The available background tags in CSS are:

background Sets all the background properties in one declaration
background-attachment Sets whether a background image is fixed or scrolls with the rest of the page
background-color Sets the background color of an element
background-image Sets the background image for an element
background-position Sets the starting position of a background image
background-repeat Sets how a background image will be repeated
AlReaud Thu, 06/09/2011 - 14:10

Controlling the color of the content text

Controlling the color of the content text

The control for the color of the text in the content area is in the Zen Starter Kit file css/pages.css

Add styles to the content area wrapper to change the default color.

#content-area /* Wrapper for the actual page content */ {
  color: #330066;
}

AlReaud Sun, 06/05/2011 - 17:42