Archive for hack
Keeping Original Node Path in a Multilingual Drupal Site
October 30th, 2010 • 2 comments drupal, hack, i18n, multilanguage, pathauto, php

Let’s say you have to make a multilanguage Drupal website… Besides English it also has to be available in Chinese and Japanese. Drupal makes it really easy for you to set up the basics. Using the Locale and I18n module, most of your site can be translated with a few clicks of your mighty mouse.
The problems come when you are trying to use pathauto in combination with placing the node title ([title-raw]) as path. You will be ending up with Chinese and Japanese characters in your URL. Most modern browsers do support this, but it’s still not a pretty sight and who knows what software/OS does not support it yet.
A solution might be typing Pinyin (for the Chinese version) in your paths… But this can be a long and tedious job (not to mention how many times your client will screw up or forget!).
Pathauto offers a relatively easy solution for our problem. We can “force” Drupal to use the original node paths for the translations too. This will not cause any conflicts as all translations are prepended with their ISO code. Just add the following code to one of your custom modules!
/**
* Because we want to use our original paths, prepended with the language identifier
* We are going to assume the default language is english!
*
* @param $alias
* @param $context
*/
function mymodule_pathauto_alias_alter(&$alias,$context) {
if($context['module'] == 'node' && $context['language'] != 'en') {
$node = node_load($context['entity_id']);
if($node->tnid > 0 && $tnode = node_load($node->tnid)) {
$alias = $tnode->path;
}
}
}
Drupal Hacker
December 10th, 2009 • drupal, hack
To better share my experience with Drupal to everyone, I’ve set up a new domain http://www.drupal-hacker.com .
Drupal is an awesome product, we all know that. But we also know that not everything works as we expect it and that any software might have it’s quirks. Here at Drupal Hacker, I try to smooth out these problems by providing patches to unmaintained modules or to ignored bugs. Last… don’t take all the sarcasm too seriously!
Optimizing Drupal 6, Gain Performance and Stability!
September 29th, 2009 • 3 comments drupal, freebies, hack, memcache, memcached, tutorials
In general, Drupal will be sufficiently stable and performant enough to run your average website. But when you are rebuilding your website or a website of your customer that gets tons of pageviews, you’ll start to encounter slowdowns, downtime & unexpected behaviour. Read more for Drupal 6 optimizing tips & tricks. Do note that I won’t be covering standard Drupal cache, I expect you to have this enabled already.
Drupal 5 Views Module Breaks Block Administration
July 31st, 2009 • 2 comments drupal, hack, snippets, views
While working on a new Drupal 5.19 powered website that has the latest view module enabled, my coworker noticed a strange feature. Once you activated more than one template and tried to switch over to manage the blocks on an other template than garland you will see it switching to garland 50% of the time. Read more »