<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Thomas Hambach - Web engineer &#187; hack</title>
	<atom:link href="http://www.rdlt.com/category/drupal/hack/feed" rel="self" type="application/rss+xml" />
	<link>http://www.rdlt.com</link>
	<description>Web development, Web design &#38; Usability</description>
	<lastBuildDate>Mon, 06 Dec 2010 09:45:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Keeping Original Node Path in a Multilingual Drupal Site</title>
		<link>http://www.rdlt.com/keeping-original-node-path-in-a-multilingual-drupal-site.html</link>
		<comments>http://www.rdlt.com/keeping-original-node-path-in-a-multilingual-drupal-site.html#comments</comments>
		<pubDate>Sat, 30 Oct 2010 07:28:13 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[drupal]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[multilanguage]]></category>
		<category><![CDATA[pathauto]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/?p=302</guid>
		<description><![CDATA[Let&#8217;s say you have to make a multilanguage Drupal website&#8230; 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 [...]]]></description>
			<content:encoded><![CDATA[<p><img title="What we do" src="http://www.rdlt.com/wp-content/uploads/2010/10/title_what_hk.png" alt="What we do" width="300" height="54" /></p>
<p>Let&#8217;s say you have to make a multilanguage Drupal website&#8230; 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.</p>
<p>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&#8217;s still not a pretty sight and who knows what software/OS does not support it yet.</p>
<p>A solution might be typing Pinyin (for the Chinese version) in your paths&#8230; But this can be a long and tedious job (not to mention how many times your client will screw up or forget!).</p>
<p>Pathauto offers a relatively easy solution for our problem. We can &#8220;force&#8221; 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!</p>
<pre>/**
 * 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(&amp;$alias,$context) {

	if($context['module'] == 'node' &amp;&amp; $context['language'] != 'en') {

		$node = node_load($context['entity_id']);
		if($node-&gt;tnid &gt; 0 &amp;&amp; $tnode = node_load($node-&gt;tnid)) {
			$alias = $tnode-&gt;path;
		}

	}

}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/keeping-original-node-path-in-a-multilingual-drupal-site.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Drupal Hacker</title>
		<link>http://www.rdlt.com/drupal-hacker.html</link>
		<comments>http://www.rdlt.com/drupal-hacker.html#comments</comments>
		<pubDate>Thu, 10 Dec 2009 13:39:34 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[drupal]]></category>
		<category><![CDATA[hack]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/?p=250</guid>
		<description><![CDATA[To better share my experience with Drupal to everyone, I&#8217;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&#8217;s quirks. Here at Drupal Hacker, I try to smooth out [...]]]></description>
			<content:encoded><![CDATA[<p>To better share my experience with Drupal to everyone, I&#8217;ve set up a new domain <a href="http://www.drupal-hacker.com" target="_blank">http://www.drupal-hacker.com </a>.</p>
<blockquote><p>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&#8217;s quirks. Here at Drupal Hacker, I try to smooth out these problems by providing patches to unmaintained modules or to ignored bugs. Last&#8230; don&#8217;t take all the sarcasm too seriously!</p>
<p><a href="http://www.drupal-hacker.com" target="_blank">http://www.drupal-hacker.com</a></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/drupal-hacker.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimizing Drupal 6, Gain Performance and Stability!</title>
		<link>http://www.rdlt.com/optimizing-drupal-6-gain-performance-and-stability.html</link>
		<comments>http://www.rdlt.com/optimizing-drupal-6-gain-performance-and-stability.html#comments</comments>
		<pubDate>Tue, 29 Sep 2009 12:57:47 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[drupal]]></category>
		<category><![CDATA[freebies]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[memcache]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/?p=215</guid>
		<description><![CDATA[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&#8217;ll start to encounter slowdowns, downtime &#38; unexpected behaviour. Read more for Drupal 6 optimizing tips &#38; tricks. Do note that I [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="lightbox" href="http://www.rdlt.com/wp-content/uploads/2009/09/drupal-man.png"><img class="alignnone size-medium wp-image-216" title="drupal man says owwhhh yea!" src="http://www.rdlt.com/wp-content/uploads/2009/09/drupal-man-246x300.png" alt="drupal man says owwhhh yea!" width="246" height="300" /></a>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&#8217;ll start to encounter slowdowns, downtime &amp; unexpected behaviour. Read more for Drupal 6 optimizing tips &amp; tricks. Do note that I won&#8217;t be covering standard Drupal cache, I expect you to have this enabled already.</p>
<p><span id="more-215"></span></p>
<p><strong>Tip #1 Caching expansion</strong></p>
<p>There are several good caching modules out there. Some are unstable or neglected by the Drupal community, others are just not worth the hassle installing. Personally I prefer using <a href="http://drupal.org/project/advcache" target="_blank">Advanced Cache</a> module. The advanced caching module is mostly a set of patches and a supporting module to bring caching to Drupal core in places where it is needed yet currently unavailable. These include caching nodes, comments, taxonomy (terms, trees, vocabularies and terms-per-node), path aliases, and search results.</p>
<p>This module will give you your first performance boost, even if you&#8217;re using standard Drupal cache to support it. There are also two (minor?) downsides when using this module. First one being that you have to hack Drupal core and second one is that it hasn&#8217;t received a lot of feedback for Drupal 6.</p>
<p>Also download the patches I have contributed to ensure *everything* is being cached correctly and that the patches work on the latest Drupal release.</p>
<ul>
<li><a href="http://drupal.org/project/advcache" target="_blank">http://drupal.org/project/advcache</a></li>
<li><a href="http://drupal.org/files/issues/node_102.patch" target="_blank">http://drupal.org/files/issues/node_102.patch</a> patch #1</li>
<li><a href="http://drupal.org/files/issues/taxonomy_56.patch" target="_blank">http://drupal.org/files/issues/taxonomy_56.patch</a> patch #2</li>
<li><a href="http://drupal.org/node/242121" target="_blank">Patches for advanced cache &#8211; topic</a></li>
</ul>
<p><strong>Tip #2 Memcache</strong></p>
<p>Memcache is probably the easiest performance improvement you can get. No patching required, you just need to set up a memcached daemon and you&#8217;ll be on your way.</p>
<p>You will want to split your caches up into several bins. This will reduce the impact of a cache rebuild on your server. You can find all the information on how to set up and install this module on it&#8217;s project page.</p>
<ul>
<li><a href="http://drupal.org/project/memcache" target="_blank">http://drupal.org/project/memcache</a></li>
<li><a href="http://www.danga.com/memcached/download.bml" target="_blank">Download memcache on nix/windows</a></li>
</ul>
<p><strong>Tip #3 Proxy caching</strong></p>
<p>Using a proxy to cache your static files is a good idea. And caching dynamic pages too is an even better idea! But&#8230; aiii&#8230; again, this involves hacking Drupal core.<br />
You can choose between varnish, squid or apache&#8217;s mod_cache. They all work the same and none of them has proven me to be a &#8220;better option&#8221;.</p>
<p><strong>Tip #4 Alternative search solution</strong></p>
<p>The Drupal search will cause a very nasty load on your database server if you get a few requests at the same time. But don&#8217;t panick, there are several options available to lighten the load.</p>
<p>Currently, apache SOLR is considered the Drupal way to go if you&#8217;re looking into an alternative search solution. Admitted, this module does get more support and has more options than any other. On the other hand, it will put strain on your web an database server while doing indexing &amp; re-indexing. The maintainers of the Apache SOLR module are looking into ways to improve this.</p>
<p>Anyway, untill they have fixed the module, I&#8217;d suggest using the Sphinxsearch module. It has fewer options, but Sphinx is able to index your website without using the Drupal API or PHP.</p>
<ul>
<li><a href="http://drupal.org/project/sphinx" target="_blank">http://drupal.org/project/sphinx</a></li>
<li><a href="http://www.sphinxsearch.com/" target="_blank">Sphinx search</a></li>
</ul>
<p><strong>Tip #5 Minimize the use of the views module</strong></p>
<p>The views module must be one of the greatest things since sliced bread. It allows you to easily set up new aggregations of nodes, users, &#8230;<br />
Too bad we can&#8217;t say the same about it&#8217;s performance. When you use this module, you have to know that you&#8217;re on thin ice. A wrong decision in your admin cp can easily cause a slow query to be generated and that&#8217;ll affect your whole site.<br />
My advice here is to hard code as many views as possible. It&#8217;ll take a bit longer, but it&#8217;ll save you pain in the long run.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/optimizing-drupal-6-gain-performance-and-stability.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Drupal 5 Views Module Breaks Block Administration</title>
		<link>http://www.rdlt.com/drupal-5-views-module-breasks-block-administration.html</link>
		<comments>http://www.rdlt.com/drupal-5-views-module-breasks-block-administration.html#comments</comments>
		<pubDate>Fri, 31 Jul 2009 11:45:31 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[drupal]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[views]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/?p=189</guid>
		<description><![CDATA[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. [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="lightbox" href="http://www.rdlt.com/wp-content/uploads/2009/07/kitten_normal.jpg"><img class="size-thumbnail wp-image-195" title="poor little kitten with big round eyes" src="http://www.rdlt.com/wp-content/uploads/2009/07/kitten_normal-150x150.jpg" alt="poor little kitten with big round eyes" width="150" height="150" /></a> 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.<span id="more-189"></span></p>
<p>The problem here lies in the views module. This module makes a call to the t() function which calls a theme function which eventually has to call init_theme() to check which template it should use. Once the init_theme() funcion has been called, the global variable $theme will be set and any other calls to init_theme() will be . Being called so early in time, the init_theme() function has no idea it still has to switch to a custom theme defined by the blocks module.</p>
<p>The fix involves <a rel="lightbox" href="http://www.vrag.ru/images/news_pic/dead_kitten.jpg">killing a kitten</a>&#8230; also know as <a href="http://drupal.org/node/144376" target="_blank">hacking drupal core</a>. Fire up your favorite editor, open up includes/theme.inc.php and find the following lines of code.</p>
<pre><code class="php">function init_theme() {
  global $theme, $user, $custom_theme, $theme_engine, $theme_key;

  // If $theme is already set, assume the others are set, too, and do nothing
  if (isset($theme)) {
    return;
  }
</code></pre>
<p>and replace it with</p>
<pre><code class="php">function init_theme() {
  global $theme, $user, $custom_theme, $theme_engine, $theme_key;

  // If $theme is already set, assume the others are set, too, and do nothing
  // patchy patchy!
  if (isset($theme)) {
  	if(isset($custom_theme)) {
  		if($theme == $custom_theme) {
  			return;
  		}
  	} else {
    	return;
  	}
  }</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/drupal-5-views-module-breasks-block-administration.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

