Drupal Development Tricks for Designers
Dani Nordin
Copyright 2012 Dani Nordin
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (.
Nutshell Handbook, the Nutshell Handbook logo, and the OReilly logo are registered trademarks of OReilly Media, Inc. Drupal Development Tricks for Designers , the cover image of a springer spaniel, and related trade dress are trademarks of OReilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and OReilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
O'Reilly Media
Preface
In the first guide, Planning and Managing Drupal Projects , we walked through the process of planning a site, figuring out the user experience, and working with content architecture. In the second, Design and Prototyping in Drupal , we started looking at how to create solid, user-centered design that works for a Drupal site, and how to allow Drupals default behavior to guide your design decisions without defaulting to making a site look Drupally.
In this guide, Drupal Development Tricks for Designers , we start looking at just a little bit of real, honest-to-goodness, developer Ninja Magick. Im going to share what Ive learned over years of building Drupal sites about setting up a development environment, getting yourself ready to collaborate on code with others, and other ways to make site building easier so you can focus on design.
Wait, What? Why?
I realize the idea of learning how to use the command line, or set up a local development environment, isnt as sexy as learning how to push the envelope of Drupal design. Trust me, I get it. But if theres one thing that prevents Drupal designers from pushing that envelope, its this: site building in Drupal isnt as efficient if you havent figured out at least a few of these tricks . Want to know why the same task takes some developers an hour or two, while it takes some of us several hours of banging our heads against the computer? Its because they know how to quickly update their modules, or how to use version control (hallelujah!) to protect themselves from bonehead mistakes.
The goal of this guide isnt to show you everything that you can possibly do to make development easier for yourself, or to provide a comprehensive guide to everything a given development tool can do; the list is entirely too long, and if youre anything like me, youll get halfway down the list before you start wondering where your coffee is and forget you ever looked at it. My goal here is simple: to help you figure out how much of this stuff you need to make repetitive tasks in Drupal take less time . The rest, you can figure out once you get the hang of it.
A Note for Windows Users
As you read through these pages, you might note that the instructions I provide here are focused on the Mac platform. Although I dont want to ignore my friends on Windows, most of what Ive learned about working with Drupalparticularly the command line stuffsimply works more efficiently on the Mac platform. Unfortunately, Windows adds a rather annoying layer of complexity to most of the command line stuff that youll see in these pages. Dear friends in the community have tried several times to work in Git and Drush on Windows, and all have fought with their machines for hours on end to get their configurations running. This complexity has led many of the developers I know to forgo Windows altogether and get things done on Mac or Ubuntu.
If you do, however, prefer Windows, you can use a program like .
The Designers Coding Toolkit
Every Drupal designer and developer has their own set of preferred applications for making their work easier; the following is a list of applications I personally use, and that many of my friends in the Drupal community also prefer. If youve got something to add to this list, Id love to hear it! Leave a comment on the website: http://drupalfordesignersbook.com.
MAMP
MAMP creates a virtual Apache server directly on your Mac. Using it, you can prototype, build and theme a Drupal site quickly on your local machine, without having to worry about FTP servers, or people accidentally seeing your half-finished work. If youre working independently, or your staging server is incredibly slow, the time savings of working locally can not be understated. Working locally is also a beautiful thing when you dont have Internet access, or access is spotty; I once got a website halfway to launch on a plane ride to Texas.
Dropbox
Dropbox allows you to manage files across the Internet using a folder on your desktop. The glory of Dropbox is that its free (for up to 2GB), it works on any platform, and it allows you to access your files on any machine that has Dropbox installed. I keep my MAMP site files in a folder within my Dropbox, which allows me to work on sites from wherever I happen to be, no matter which computer Im working on. The one challenge to the Dropbox/MAMP combination is where databases are stored; although you can easily store your site files in a Dropbox folder, the database files exist on whatever machine youre on, which means that you have to sync the databases from one machine to the other if you want to do work on a different machine. This can be done using a program like Navicat (see ) makes this process relatively easy.
Coda
I first mentioned Coda in Design and Prototyping for Drupal , but its worth mentioning again. Coda is a relatively inexpensive (under $100) application for coding websites. Not only does it allow you to code your pages and upload them in the same screen, it also has the ability to connect to Terminal on your remote server from within the application, which is useful when youre running shell commands, like Drush or Git. Most importantly, Codas Clips library allows you to keep commonly used code snippets in one place and insert them into your HTML simply by double-clicking. This is extraordinarily useful in theming; I keep CSS3 snippets and Drupal theme hooks in the Clips library, so I can add them to my template files at any time.
Terminal
Terminal is a native application in Mac OS X that lets you run command-line prompts. If youre going to use Git or Drush, you will need to get cozy with Terminal.
Navicat
Navicat is a Mac-based application that helps you manage databases. While you can also use PHPmyAdmin (which comes with MAMP), what I like about using Navicat is that its highly visually oriented, and you can connectin one locationnot just to databases on your local hosting environment, but on other hosting environments as well, as long as youve set up a way to access the host remotely. As hosting companies tend to deal with remote access differently, make sure you check your hosting companys FAQ or support wiki for how to establish remote access. With Dreamhost, which I use, its generally as simple as entering the IP address youre trying to access the host from into an allowed hosts field in the users profile.