Drupal 7 – Multi language front page

It’s not possible in Drupal 7 to define a front page per language with the core or i18n module or something. However with a little bit of code it’s still not so hard to do.

Create a custom module “alter” for example. Create the folder in “sites/all/modules/alter”. Create “alter.info”

name = Alter
description = "This module performs several minor changes"
package = Custom
version = 7.x-dev
core = 7.x

And create a file with the name “alter.module”. And put the following code in it with your own adjustments for the right languages, default front page and the right nodes.

function alter_language_init() {
  switch ($GLOBALS['language']->language) {
    case 'nl':
      $GLOBALS['conf']['site_frontpage'] = 'node/1';
      break;
    case 'en':
    default:
      $GLOBALS['conf']['site_frontpage'] = 'node/2';
      break;
  }
}

Enable the module in the site configuration and you’re done!

Tags: ,,