Drupal coder

Overriding theme_blocks when using Block Translation module (i18n)

I just pulled my hair out looking for what caused this, but eventually found it after scanning the module files. The issue was that overriding hook_theme_blocks wasn't possible in some theme. The version in the theme wouldn't get called at all, even after rebuilding the theme registry by clearing the cache. The culprit was the Block Translation module.

If you're using the Block Translation module (i18n_blocks, part of the Internationalization module) and want to override theme_blocks, you should instead override theme_i18n_blocks. The Block Translation module implements hook_theme_registry_alter and alters theme_block function to i18n_blocks.

function i18nblocks_theme_registry_alter(&$theme_registry) {
  $theme_registry['blocks'] = $theme_registry['i18nblocks'];
}
February 18, 2010Drupal, i18n, theming

Comments

Saved me a lot of time!

The following patch fixes the problem by providing a cleaner way for translating blocks: http://drupal.org/node/457512#comment-2352474.
It's not such a big deal for theming purposes, but it conflicts with other modules that use that registry alter 'hack' (e.g. Context)...

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options