Drupal Tutorial

Installing xhprof and XHGui on a Dreamhost Ubuntu 12.04 VPS to diagnose Drupal 6 performance

One of my websites has been running very slow for years - every so often I try to figure out why it's slow, and recently it had been suggested to install xhprof to gather some data. The website is a Drupal 6 site that gets 1000+ visits a day, and is an active forum website with lots of people chatting away about electric vehicles. The server is a VPS rented from Dreamhost. The latest iteration of Dreamhost VPS's uses SSD disks, and a customized version of Ubuntu 12.04.

Fixing Drush when it says a "higher level bootstrap" is required, even though you're inside a Drupal website's working directory

I'm trying to get ready for a Drupal 8 port, and one of the steps is to get Drush set up. Nowadays that means setting up Composer and running some magic commands with Composer that supposedly sets up Drush. The problem then came when I cd'd into the root of my Drupal 6 site, and tried to run "drush pm-list --core" to generate a list of installed modules to prepare a readiness spreadsheet. The error message that came up gave me a big WTF feeling:

Fixing broken images when Drupal adds _0 to uploaded file names; filename and filepath differs

druplicon.large_.pngOccasionally on Drupal sites (perhaps only Drupal 6), uploading a file to a file field, or the file uploads area on a node, results in the "filepath" indicating a different name than the "filename". That is, in the data model for a Node, you can attach files in the "uploads" or in a CCK field (in Drupal 7 this is slightly different) and each attached file is an object (or array) containing attributes named "filename" and "filepath".

Eliminating duplicates in Views 3 Drupal 6 when the "distinct" and "group by" features don't work

Yes, Drupal 6 is water under the stream except for those of us still maintaining Drupal 6 websites. On one of my sites I'm trying to bring the module status into 2014, because they'd last been updated in 2012 and Views hadn't even been upgraded to Views 3. It was pretty straightforward to generate a Drush Make file to generate updated code for the site. A couple of the Views didn't get properly upgraded to Views 3, and in most cases minor tweaks were all that was needed. But one View had a major flaw - it generated lots of duplicated content.

Fixing things when your Drupal content fields don't display or you can't edit the field

Suppose you've added a field to a Drupal content type, but puzzlingly the field doesn't display on the node edit page? Or the field doesn't display when you view a node? Why would that happen? Maybe, you think, a custom themed node edit page simply didn't display the field? All kinds of ideas might come to mind while you're scratching your head wondering what might be going on. Adding a field to a content type should make it easy to edit and display data in that field, right?

Add a Google CSE to a Drupal 7 site without using google_cse module

The https://drupal.org/project/google_cse module appears to be a dead project - the Drupal 7 port hasn't had any activity in over 2 years. If you want to use a Google Custom Search Engine (CSE) on a Drupal 7 site, what do you do? Turns out it's relatively straight-forward to just generate the CSE over on Google's website, take the code and paste it into a Block, and that's it.

Getting email validation straightened out for successful email transmissions (DKIM, SPF and PTR, oh my!)

One of the things Drupal does is generate emails for a variety of reasons. For example new account registrations include a step to validate the account, by sending an email containing a validation link. On the large online community website I run, a long-running problem has been that the validation email does not always get delivered. This shows up as a user registration that never gets validated.

Generating Apache style .htaccess redirects from Drupal's Path Redirect module

The "Path Redirect" module for Drupal 6 (http://drupal.org/project/path_redirect) is an excellent way to set up redirects from one URL to another. This module can be used for any purpose where you want the HTTP request for URL's on a Drupal website to automatically redirect to another URL. For example :-

  • you might want to have a nice URL to promote for some excellent product (example.com/excellent-camera) that lands on a merchant website while hiding the complexity of the merchant URL (making sure to include the affiliate link).

Make your own tiny URL service in Drupal with Shorten or ShURLy modules

Short (or tiny) URL's are great for sharing links on various social media services. Twitter's 140 character limit places a premium on bytes better used for words than URL's, e-mail clients get hinky with long URL's, and so on. It's possible to use services like tinyurl.com or bit.ly to create your short links, but as Drupal users we have a powerful platform at our fingertips. Maybe it can do the short URL natively or maybe it can be programmed to automatically retrieve short URL's from the existing services.

Make your own tiny URL service in Drupal with Shorten or ShURLy modules

Short (or tiny) URL's are great for sharing links on various social media services. Twitter's 140 character limit places a premium on bytes better used for words than URL's, e-mail clients get hinky with long URL's, and so on. It's possible to use services like tinyurl.com or bit.ly to create your short links, but as Drupal users we have a powerful platform at our fingertips. Maybe it can do the short URL natively or maybe it can be programmed to automatically retrieve short URL's from the existing services.

Pages