Dec21

My favourite Drupal modules and why you should use them

21-Dec-2007
Filed under: Drupal, Drupal 5.x

Drupal's power and flexibility really comes into its own when you start using add-on modules to extend its functionality. Finding the really useful modules amongst the hundreds that are available can be a daunting task. To help you sort the wheat from the chaff, I've compiled a list of the sixteen Drupal modules that I use in almost every site I build.

Dec06

Default text field value that disappears on focus

06-Dec-2007
Filed under: JavaScript, jQuery

See the search form top right? Click the search box. See how the default text disappears and then reappears when you click away from the search box? Here's how you do it.

The script below searches the page that it's inserted on for all form input fields that have a class of default-value applied. Each form input field must have a unique ID.

Nov29

AlphaImageLoader and links not working in IE6

29-Nov-2007
Filed under: CSS

Are you using the AlphaImageLoader filter to get your PNGs working properly in IE6? Are your links not working when nested inside an element with a PNG background image?

Here's how to fix it: IE AlphaImageLoader, Transparent PNGs & Links

By the way, this will also work if you're using IEPNGFix by TwinHelix.

Nov28

Exploring Drupal's Htmlarea module

28-Nov-2007
Filed under: Drupal, Drupal 5.x

I've spent the last two days looking at Drupal's Htmlarea module. Similar to the TinyMCE module, this module acts as a wrapper for the Xinha WYSIWYG editor (Xinha is a fork of the original htmlArea WYSIWYG editor).

I like Xinha, though, as you might expect, it's not without its fair share of issues. The developer community for Xinha seems to be quite active though, and bugs are being addressed.

I've assembled a few preliminary notes here that might help you on your way:

Nov21

Output secondary links as a menu tree

21-Nov-2007
Filed under: Drupal, Drupal 5.x

Thanks for this posting goes to rapidsynergy for posting the solution in this comment on the Drupal forum.

Problem: You're using $secondary_links to display the children of the active menu item in $primary_links, but $secondary_links has children too and they aren't displaying when their parent becomes active.

Solution: Add the following snippet to your template.php file:

Nov14

Using the FCKEditor file browser with TinyMCE on Drupal

14-Nov-2007
Filed under: Drupal, Drupal 5.x

TinyMCE on Drupal offers support for user uploads of files (via the insert image and link dialogs) through the use of the IMCE module. Enable this module and the upload buttons automatically appear in these dialogs.

It's just not very good, is it?

Nov13

Create new template positions for block placement

13-Nov-2007
Filed under: Drupal, Drupal 5.x

This little trick will let you create new template positions for your page.tpl.php, which you can use as containers for your blocks.

Add the following snippet to your template.php:

Nov13

Creating a block to list taxonomy terms

13-Nov-2007
Filed under: Drupal, Drupal 5.x

There's a nice post over at Tela-Web on a quick and easy way to create a block to display a list of taxonomy terms for a given vocabulary.

Check out: Another taxonomy term list for Drupal.

Nov13

Setting up a Drupal 5 site from scratch

13-Nov-2007
Filed under: Drupal, Drupal 5.x

The following guide is a representation of the steps I usually take when starting development on a new Drupal based website. It is what I consider to be "best practice", but some of it is quite prescriptive and therefore may not suit your needs. Feel free to pick and choose the steps to take as you see fit.

Oct17

Clean strings with regular expressions

17-Oct-2007
Filed under: PHP, Regular expressions

The following case-insensitive regular expression snippet will strip all non-alphanumeric characters from $string.

<?php
$string
= 'abc123_%$£';
$string = preg_replace("/[^a-z\d]/i", "", $string);
echo
$string; // Result: abc123
?>