Drupal 5.x
Specify an alternative jQuery library for a particular page on your Drupal site
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.
Give your Drupal blocks a more descriptive HTML ID attribute
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:
Restrict access to Drupal nodes, node types and menu items
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.
Showing the nested sub-navigation of the active primary link
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?
Add tertiary links to your Drupal template
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.
Disable TinyMCE on a per-field basis in Drupal
There's a post on avocadoshake.net, which describes how to disable TinyMCE on a per field basis in Drupal.
Instruct the Views module to add class values to each item of a list view
I had a client ask me recently to help them identify the first and last nodes of a list view by adding a class to each of the list items.
This can be done pretty easily by overriding the appropriate views theme function and injecting some of our own code into the array of rendered nodes just before they are converted to a list and displayed.
Simply paste the snippet below into the file named template.php residing in your theme's folder. If there's no template.php, go ahead and create it.
My favourite Drupal modules and why you should use them
Update: I've compiled an updated list of essential modules for Drupal 6 (and beyond).
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.
Exploring Drupal's Htmlarea module
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:
Output secondary links as a menu tree
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:






