Work
Setting up email subscriptions and notifications in Drupal 7
Drupal Level: Beginner-Intermediate
Email notifications are the glitter of community sites: very few people passionately like them, but you'll never get rid of them. Probably the most typical use case on a Drupal site is to send an email notification to let a node's author know that someone's commented on their node. I just spent the good part of an afternoon setting this up on a Drupal 7 site, and thought I'd pass along some time saving tips.
Don't Repeat Yourself: Enterprise Data is Hard
I usually like what Ted Dziuba has to say but his rant, The Most Important Concept in Systems Design, missed the mark on a few points and ultimately misunderstands the problem on a fundamental level. Go read Ted's article if you haven't already, then we'll jump into some counterarguments and finally why the whole rant is misguided.
Ready?
1. Using Solr to Search a Database
db_affected_rows() is annoying
Given the following Drupal code:
and assuming that dummy_column doesn't exist in the users table, what is printed? Here's a hint from the php manual:
mysql_affected_rows()
Returns the number of affected rows on success, and -1 if the last query failed.
If you said "-1" like me, you're wrong (at least some of the time). The code above will return "1" if you have watchdog enabled.
No, your brand doesn't need an API
I just read Adam Klienberg's Mashable post, Why Every Brand Needs an Open API for Developers, and there was one good piece of advice in the whole thing: "Before you grab for that shiny object, ask yourself what you’re really trying to accomplish and how best to make that happen."
Readable emails from Outlook in Mail.app
Ever get emails from people using Outlook/Exchange and have to squint to see what it says when using mail.app? Close mail.app, hop over to the terminal and do this:
- defaults write com.apple.mail MinimumHTMLFontSize 13
Start up mail.app and boom, readable email.
How to use Apache's Proxy on Drupal's Files directory
Drupal's files directory can get enormous, and it's best not to keep it in version control. Here's a way to use Apache's proxy module to point your local environment directly to your dev/live site's files directory so you don't have to download it.
In your httpd.conf:
- ProxyRequests On
- ProxyVia On
- <Proxy *>
- Order deny,allow
- Deny from all
- Allow from localhost
- Allow from all
- </Proxy>
- <Location /sites/default/files/imagecache/>
- ProxyPass http://dev.yoursite.com/sites/default/files/imagecache/
- </Location>
How to use a mailing list
When you reply to someone on a mailing list, your mail software will populate the "To:" address one of two ways: either to the person who wrote the post you're replying to, or to the entire list. This depends on how the list is set up.
There is a very simple way to determine if you're replying to a person or to the whole list (which might be bad if you're giving out your rates). Follow these three simple steps to avoid failing at mailing lists:
1) Read a message.









