Serving different robots.txt per domain with a single codebase

I just found myself with the task of excluding search robots from one site of a multisite Drupal installation while keeping the other site fully crawlable. As multisites share a single code base per definition there is obviously only one robots.txt for all sites inside a multisite installation. Eli suggested a great way of overcoming this problem by simply using a domain based rewrite rule. It takes not even a minute to implement and works smoothly \o/

RewriteCond %{HTTP_HOST}    domainone.com$ [NC]
RewriteRule ^robots.txt      robots_for_domainone.txt [L]

RewriteCond %{HTTP_HOST}    domaintwo.com$ [NC]
RewriteRule ^robots.txt      robots_for_domaintwo.txt [L]

Importing Organic Groups membership from CSV data using feeds module

Finally! You'll need to hack entityreference using this patch! After patching you can change your field mapping to "Entity Reference by Entity ID" ("default was Entity Reference by feeds GUID"). So in plain english: I was now able to import legacy data (after querying my old sql database to change legacy IDs to the node ids of my organic group nodes) content and creating/maintaining group memberships. Awesome!

Omega 4 comes with SASS out of the box

With great pleasure I just read Kathryn McClintock's announcement of the latest iteration of Omega, my favorite responsive Drupal base theme.

Glad to hear they're dropping the overly complicated zone and region configuration in favor of a more code-centric approach. Also it's really a good time to start building CSS with SASS, especially as I just recently decided I really ought to jump aboard the CSS preprocessor train, with SASS being probably the best choice these days.

Localize Simplenews Confirmation Emails in Drupal 6

I hope I won't need this anymore, but just in case for future reference: On Drupal 6 and Simplenews 6.x-2.0-alpha5 I had issues when I tried to create a multilingual newsletter. Confirmation messages kept on being sent only in one language - the strings defined on ´admin/settings/simplenews/subscription´. String translation didn't help me, although I sticked with the documentation. When I enabled the following variables as being multilinugal variables I was able to change those settings individually per language - and now confirmations are being sent in the proper language.

Just add the following snippet to your settings.php, flush caches and edit Simplenews subscription settings for each of your enabled languages:

Adding a pager to browse between nodes

For anyone in need of a node-to-node pager that respects domain assignment and a content's language with the added benefit of setting your own method of sorting, check out the Free Pager module

Free pager creates a new views display type, which can be configured to any liking (for me that is filtering only nodes that are available on the current domain and in the currently active language). The pager itself can then simply be placed anywhere via block configuration settings.

Finally a working pager that can be customized in any imaginable way :)

Adding body classes to Drupal depending on whether a region is rendered

Here's a simple way to add body classes to your theme in dependence of the visibility of a region. The variables array shown here is specific to the Omega theme, normally it's something like $variables['classes_array'][]

Just put the following code into your theme's template.php:

function MYTHEME_preprocess_html(&$variables) {
  // Add a body class if first sidebar is not being rendered
  if(!isset($variables['page']['content']['content']['sidebar_first'])) {
    $variables['attributes_array']['class'][] = 'no-sidebar-first';
  } else {
    $variables['attributes_array']['class'][] = 'sidebar-first';

Prevent CKEditor from creating empty paragraphs upon pasting rich text

When using CKEditor with Drupal more often than not annoying empty paragraphs <p>&nbsp;</p> slip into your article when pasting formatted text. To prevent this stupid behavior it turns out you can set config.autoParagraph = false in CKEditor's configuration at sites/all/modules/ckeditor/ckeditor.config.js. Of course it's not a good idea to hack this part of the module directly, so I'm still gonna have to look for a way to set that option independently (I guess there even is an option available on the CKEdtior configuration page that allows to load a customized config file).

Anyways, I needed to get rid of those pesky paragraphs ASAP so here's the relevant part of my ckeditor.config.js

CKEDITOR.editorConfig = function(config) {
    **config.autoParagraph = false;**

In case you're worried: this does not keep CKEditor from inserting paragraphs upon hitting the enter key.