CiviCRM Mailing Not Being Sent To All In Group

If you create a CiviCRM group with, say, 1,000 contacts in it and then go to create a mailing using the same group and it only says it will send it to 750, it's likely because some of those contacts are "on hold." On hold simply means that the system has determined the email address associated with the contact to be not worth sending to (i.e., dead). This could be caused by the emails bouncing for any number of reasons.

To avoid unnecessary continued bouncing, CiviCRM flags them as On Hold and prevents them from being included on future mailings.

Create a Redirect in Drupal's .htaccess For The Base URL

I recently needed to redirect a client's traffic from their old URL to a new one. In this case, they wanted any traffic going to plain example1.com to go to example2.com/blog and all other traffic to go to example2.com/[equivalent URI] (e.g., example1.com/about --> example2.com/about).

To do this, I messed around with rewrite rules and conditions for a while, until I decided on what seems to be a fairly straight forward solution:


# Redirect example1.com to example2.com/blog
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule ^$ http://example2.com/blog [r=301,L]

Redirect

A GTD "trusted system" -- todo.sh

The Rave

Yesterday was the birthday of a shell script that Gina Trapani uses to (her words) "run her life." I am a huge Lifehacker fan, and when Gina started Smarterware I subscribed to its RSS as well. Though a lot of posts overlap, some do not - and it's good to keep up with what else Gina is doing. She's a very smart woman.

Uh-oh, I upgraded to Lucid Lynx but need PHP 5.2 for Drupal!

Last night I hastily decided to upgrade to Lucid Lynx on my main development machine. Generally, I try and wait a few months till things settle, but nearly 100% of the time that doesn't work. After a short battle with my wireless and some other small things, I finally settled back into "work mode" and wanted to get started working on a project I'm working on for Appalachian State University.

Network At DrupalCon

Networking in most social situations is difficult enough, but when you throw thousands of (often) socially awkward and introverted geeks together, the task becomes even more overwhelming. And these aren’t just any geeks, these are Drupal geeks, which means you’ve got a ton of smart, dedicated and interesting people to meet -- it’s just that some might need a little nudge. If you haven’t already, I highly recommend “Work the Pond!” by Darcy Rezac -- it, along with my own experiences, is what powers the following advice:

Introduce Yourself

Drupal notifications that don't work for ___ (comments, nodes, whatever)?

I spent a few hours wading through something yesterday that I hope will save some other people some headaches.

I had the notifications module on, and it was sending notifications for node creations and updates just fine, but it seemingly wasn't sending anything when I commented on a node. It would TELL ME it did ("notification sent to x other users") but I would never get an email.

Theming Webform Emails

Wow, it seems that Drupal's Webform module has come a long way since I last used it (which I believe was Drupal 5.x). It's so convenient and really latches onto the new template hints and stuff from Drupal 6 (here I am talking about it while Webchick announced yesterday the D7 criticals queue is under 200, w00t!).

Private and Public File Access in Drupal

If you're like us, we usually only want to have SOME files "private" and not ALL files as Drupal is limited to all-or-nothing out of the box. There are some modules out there that do this, but honestly it's pretty easy to do yourself.

Let's say you don't want anonymous users (or search engines) to download any files in your sites/default/files/private folder. Create a .htaccess file in the folder you wish to protect and add the following and save (this is for Apache, but similar for Windows systems):


RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^GET$ [NC]

Using drupal_execute vs. node_save

There seems to be much debate regarding when to use node_save versus drupal_execute. Personally, I like the idea of drupal_execute, since it's just like the regular form executing--it handles validation for you, for example. This is an example of where I had to use node_save, but still needed validation.

Resolving Drupal CVS Merge Conflicts

We manage our sites via SVN by first checking core and contributed Drupal modules from cvs.drupal.org. An explanation for this deserves its own post (coming soon...), but basically we check out from cvs.drupal.org and then import that into our SVN repository.

SVN add Updated Drupal Modules With Ease

With modules such as CCK, you'll often notice that after updating it via CVS that you are left with a bunch of new objects (new translation, css, and other files) in folders and subfolders. Rather than svn add'ing each file and/or subfolder independently, try this in the root folder of the module you updated:

svn add * --force

That will add all the new files you acquired with your most recent CVS update.

Hide The Drupal Files Folder From SVN

It's best practice to hide your "files" folder from SVN since you probably don't want to inundate your repository with and endless number of updates. If you do this:


svn propset svn:ignore "*" sites/default/files
svn commit -m "Hide the files folder"

Then you should be all set, and you won't see any more "?" when you do a svn status command.

Why Can't I Edit a Drupal Node That I Have Permission to Edit?

Okay, this one gets me all the time. I grant a role the ability to edit certain nodes and when they log in and try to edit a page, there's no edit tab!

Chances are that if you've tried everything else, you need to grant that role permission to use whichever input type you've set for that node or set of nodes. To do so:

  1. Edit your node and check what input type it is set to use
  2. Go to Site Configuration > Input Formats and then make sure that the corresponding input type is configured to allow the role to use that type.

Database Migration Script

Here's a handy BASH script I wrote to pull down one copy of a database to a local version using an SSH tunnel. It's not super-secure, so it kind of assume that you have the script hosted on a local machine, securely (the DB password is in the script!).

First, go put a host named "tunnel" in your hosts file (usually /etc/hosts on *nix-type environments), that points to localhost 127.0.0.1 (mysql can get cranky when you try to connect to "localhost" - it always tries to use a local socket when you say that, so this is a bit of a workaround to make it work through the tunnel.

Remove CiviCRM Contacts From One Group Who Have Unsubscribed From Another

We run several CiviCRM instances with our Drupal sites. One issue we ran into recently concerned contacts who unsubscribe from one group which was a subset of a larger group of contacts (of which they also belonged). When they would unsubscribe from one, they would still be subscribed to the other and thus were still receiving the newsletter. Aside from the fact that the group/newsletter setup was a bit un-ideal, we had to address the issue and manually unsubscribe the contacts from the other group. Here's how we did it:

Replicate MySQL's MD5() Function in SQL Server 2005 Using HASHBYTES()

MySQL and PostgreSQL's MD5() functions are nice, simple, ways to hash your data. Unfortunately, SQL Server 2005 and up (sorry, in order to get it working in SQL Server 2000, you'll need to try a stored proceedure), you can use the HASHBYTES() function.

In a recent SQL Server port of the Actions module for Drupal 5, I ran into the following MySQL query:


SELECT aid FROM {actions} WHERE MD5(aid) = '%s'

Taking Care of Those Pesky CVS Entries.Log Files After Updating Your Drupal Module !

Sometimes when I update a Drupal module or core install, some CVS files are removed - namely Entries.Log files. When you go to svn up your changes, it will complain saying that there are files in your repository that no longer exist in your working copy (signified by the ! mark). To get rid of these, try using the following bash script (you can put this in your .bashrc file in *nix, if you're using the bash shell of course):

Drupal CVS Checkout Shortcuts

I've recently found myself having to constantly search for the CVS checkout command for drupal modules. Rather than memorizing it, I figured it was easier to create a script that does checkouts for me. Better yet, I found others who have already done that part for me. Here are some really slick .bashrc or .bash_profile scripts for dealing with CVS, SVN, and Drupal:

Checking Out a Module

Update Subversion on Mac OS X

If you get the following error

svn: This client is too old to work with working copy '.';
please get a newer Subversion client

... or you just want to update your subversion client (command line), try the following:

  1. In Terminal, type "svn --version" to find out what version you currently have
  2. Go to http://www.open.collab.net/downloads/community and download the latest client for OS X and install it. This will install the new svn into /opt/subversion/bin

Creating a .bash_profile on your mac

A typical install of OS X won't create a .bash_profile for you. When you want to run functions from your command line, this is a must-have.

  1. Start up Terminal
  2. Type "cd ~/" to go to your home foler
  3. Type "touch .bash_profile" to create your new file.
  4. Edit .bash_profile with your favorite editor (or you can just type "open -e .bash_profile" to open it in TextEdit.
  5. Type . .bashrc to reload .bashrc and update any functions you add.

Installing Webmin on Ubuntu

Simply:

  1. Copy the URL to the latest Debian version at http://webmin.com/download.html
  2. Run "wget [URL]" from your command line, replacing "[URL]" with the URL you got from the Webmin site (e.g., http://prdownloads.sourceforge.net/webadmin/webmin_1.460_all.deb).
  3. run "dpkg -i [the file you just downloaded]"
  4. If you get an error saying that webmin depends on other modules not yet installed, install them: sudo apt-get install libnet-ssleay-perl libauthen-pam-perl libio-pty-perl libmd5-perl (include any others that were listed as well)

VirtualDocumentRoot FTW!

One thing I got to hear about at DrupalCon during the Q&A at Sacha Chua's Totally Rocking Your Development Environment was someone who popped up quick and mentioned the utility of VirtualDocumentRoot, a directive for Apache which lets you automatically go find the folder to server the site out of based on the incoming host header.

Clean URLs / URL Re-writing on Mac OS X Leopard

For whatever reason, the whole LAMP stack on a Mac is a bit of a pain to set up. If you want to get URL re-writing to work, you'll need to do the following (among other things):

To turn on clean URL's on Mac OS X 10.5.6:

Add "AccessFileName .htaccess" to /private/etc/apache2/httpd.conf (or wherever your httpd.conf file is located)

Then dependant on where you have installed drupal either:

Improve Your SEO By Redirecting Non-WWW Traffic to WWW

Setup the WWW Subdomain

If you haven't already, make sure you allow visitors to access your site through your root domain as well as the www subdomain (e.g., http://example.com and http://www.example.com). Even though the www subdomain isn't required, some still type it in out of habit. You can do this either by adding a CNAME record with your domain's registrar or by adding a ServerAlias directive in your Apache virual host httpd.conf.

Congratulations! You've successfully decreased your site's SEO performance / PageRank.