The Web Developer's Blog has been discontinued. I am now maintaining a new blog that is related to my company, Blue Piccadilly. The most popular articles from this blog (by monthly page views) have already been republished on the new blog, and indeed those original pages on this blog are being redirected to their new location. I'll probably keep these pages up here for a while. At least until the domain expires.

Nov22

Add tertiary links to your Drupal 6 template

22-Nov-2010
Filed under: Drupal, Drupal 6.x
I have previously covered this topic for Drupal 5, but below are instructions for adding tertiary links to any Drupal 6 template. By default, Drupal provides for primary (level 1) and secondary (level 2) links. But what if you want to display the children of the secondary links in a separate menu?

Nov15

Essential Drupal modules (revisited)

15-Nov-2010
Filed under: Drupal, Drupal 6.x

Almost three years have passed since I compiled my first list of essential Drupal modules and a lot has changed since then, not the least of which is that Drupal 6 has long since replaced its older sibling. I thought it was high time for an update.

Nov14

jQuery Fundamentals - A completely free book for learning jQuery

14-Nov-2010
Filed under: JavaScript, jQuery

If you've been trying to learn (or learn more about) jQuery, and you don't know about Rebecca Murphey's excellent Creative Commons licenced book jQuery Fundamentals, you're missing out.

Jul31

Exclude all nodes of a Drupal node type from the search results

31-Jul-2009
Filed under: Drupal

Here's an easy way to entirely exclude all nodes of a certain type from your search results using hook_db_rewrite_sql. Simply create a Drupal module containing the following snippet, and change the $excluded_content_types array to contain the content types you wish to exclude:

Feb20

Specify an alternative jQuery library for a particular page on your Drupal site

20-Feb-2009
Filed under: jQuery, Drupal 5.x

Drupal 5.x comes bundled with a fairly outdated version of the jQuery library. Simply downloading the latest version of jQuery and replacing Drupal's jQuery library is not recommended, as this causes compatibility problems with Drupal's own use of jQuery.

Nevertheless, there are times when you might have a requirement to use the latest version of jQuery. For instance, you might want to make use of a jQuery plugin that's not supported by the default version.

Dec11

Use Mod Rewrite to redirect visitors requesting a specific host to a new host

11-Dec-2008
Filed under: Server stuff

To redirect visitors requesting a specific host name to a whole new host name, use the following snippet in your .htaccess file:

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{HTTP_HOST} ^(www\.)?oldhost\.com$
  RewriteRule ^(.*)$ http://www.newhost.com/$1 [R,L]
</IfModule>

This will check for visitors requesting either oldhost.com or www.oldhost.com and redirect them to www.newhost.com.

Oct29

Give your Drupal blocks a more descriptive HTML ID attribute

29-Oct-2008
Filed under: Drupal, Drupal 5.x

I don't know about you, but I like my HTML ID attributes and therefore my CSS selectors to be descriptive. It makes both my HTML and CSS more readable, and lets me scan a document more effectively, locating the section I need with relative ease.

If you create a custom Drupal block the system will typically output a line of HTML which might look like this:

Oct28

Restrict access to Drupal nodes, node types and menu items

28-Oct-2008
Filed under: Drupal, Drupal 5.x

If you want to restrict access to certain pages, or all pages of a certain type, on your Drupal website, I recommend the Content Access module. Unfortunately, the Content Access module fails to hide the menu item of a restricted page.

Oct23

Showing the nested sub-navigation of the active primary link

23-Oct-2008
Filed under: Drupal, Drupal 5.x

This seems obvious, yet every time I start a new Drupal project I spend at least 10 minutes looking at older projects trying to find the solution.

I'm talking about getting Drupal to show the sub-navigation of a primary link when that primary link is active.

The solution is so simple it invariably leads to a facepalm: Instead of using the provided $primary_links variable in your template, enable the primary links block on the block configuration page.

Why can't I remember this?

Jul02

Add tertiary links to your Drupal template

02-Jul-2008
Filed under: Drupal, Drupal 5.x

Update: For a version of this snippet compatible with Drupal 6, see Add tertiary links to your Drupal 6 template.

By default, Drupal gives you two menu variables to use in your templates. $primary_links contains the first level of navigation and $secondary_links contains the child pages of the active primary link.

But what if you need to display the children of the secondary links? Fortunately, Drupal user rapidsynergy has done the hard work for us in this comment he posted on the Drupal website. I'll reproduce his code here (with slight modifications) for future reference.

< Prev123Next >