Drupal 7

Drupal 7 and MySQL sockets

I recently switched from a mysql.com implementation of MySQL to MacPorts on my local, and the Drupal sites would no longer load.

The MacPorts my.cnf file turns off networking, so that multiple versions of MySQL can be run. In doing so, one must then use socket files to access MySQL instead of TCP/IP. This requires a change to the database config in the settings.php file.

Simply add the path to your socket file as an additional line in the database config array, as follows:

'unix_socket' => '/<path>/mysqld.sock'

In a Rush? Install with Drush!

You know how to install Drupal the normal way, but there is a shortcut, if you have drush.

Drush provides a command (site-install) for downloading modules. Drupal, itself, is kept as a project in the modules section of Drupal. So, drush can download it, as well. Installing Drupal can be done with another drush command. Here is how to install Drupal, in 3 easy steps:

Don't Stress Over Local Passwords

Are you working in a multi-server environment, such as local, staging and production? If you don't have User 1 (or some other user) access in your local setup, it's easy to remedy.

Enter drush and its user-password (upwd) command. Changing a password is a cinch, whether you know the existing one or not, if you have drush access to the site, which you hopefully do, on your local development server.

drush upwd <username> --password="<new password>"


drush upwd admin --password="let-me-in"

Giving Nodes a Wardrobe - meet page_is_node() and drupal_is_front_page()

If you've been using Drupal for awhile, you probably understand template hinting and how you can format one content type differently than another, by having a template file such as


Recently, however, I had the need to format a single content type differently depending on where it was presented:

To-Go Menu

Have you ever wanted to have a menu item open in a new window, when clicked? The standard menu dialog does not offer the option of a target for the menu link. So, what to do? A little jQuery magic!

1. Inspect the menu item, or view the page source, and find it's id...something like this:

<div id="menu-231">
  <a href="wherever">My menu link</a>


2. Add the following snippet to your theme. How you will add it depends...see the footnote at the end:

You Have Some Options

Implementing Option-only Pricing in Drupal Commerce (D7)

Drupal Commerce can be confusing to get one's arms around, even if (or especially if) coming from using Ubercart or some other relatively point-and-click cart. I recently had the need to do something I considered a simple requirement, and having retail experience, something intrinsic to most catalogs: products with option-only pricing.

Drupal and permissions - avoiding 'The directory sites/default/files is not writable' error

Have you moved a Drupal site to another server and received the error 'The directory sites/default/files is not writable' ?  The site worked on the previous server, and the permissions seem the same. Ah, an easy fix...make the permissions for the files directory 777. Noooo!

Let's take a look at what the numbers in the permissions setting mean.

Subscribe to Drupal 7