home resources search newsjoinmembers: 6958
PHP Flash Java Ruby Windows Linux
marcusjohans... | Sat, 2007-12-22 07:09  tags: , ,

First a caveat. This is an ugly solution to a Drupal weakness. What we needed was a way to get panels module to work in three different languages. This solution was the quickest and easiest way of accomplishing the task without going into the core code and changing things.

Before you start you have to do the normal installation of i18n module and all of its companion modules. Look to the Drupal.org website and download the needed materials and information before you start.

1. Create a page and call it "start" on the page place the following PHP code. Code does the following. When the abbreviation for the language is seen in the URL there is a redirect to the panel pages url. When you create a panel you are asked to give the URL that the user needs to surf to to seen that panel. In the case of the code below language 'arb' would be redirected to the panel 'arabic'.

ollowing the above guideline you should create a panel for each language. Below I have done three panels for english, dutch and french. Each one of these has a corresponding language prefix created by the i18n and locale modules. So I grab the i18n url 'fr' and redirect it to the panels URL 'francais'.

<?php

if(i18n_get_lang() == 'fr') {
  
drupal_goto('francais');
} elseif (
i18n_get_lang() == 'nl') {
  
drupal_goto('dutch');
} else {
  
drupal_goto('english');
}

?>

Now use path alias and set the node/?? to a friendly alias called "start".

2. Now you need a bit of code to keep the page from reloading in a loop. Create a block and call it "start page language switcher" and place the folling PHP code in it.

<?php

if(i18n_get_lang() == 'fr' && arg(0)!='francais') {
  
drupal_goto('francais');
} elseif (
i18n_get_lang() == 'nl' && arg(0)!='dutch') {
  
drupal_goto('dutch');
} elseif (
i18n_get_lang() == 'en' && arg(0)!='english') {
  
drupal_goto('english');
}

?>

Using the panels module is much easier and more flexible than using just the frontpage module. Panels allows for views, one click changes for layouts and I can pre-create a layout.

printer-friendly version

marcusjohanssson's picture
Drupal and javascript programmer with a careful eye on usability. Marcus Johansson - System Developer
Thoughtbox - So what did you think?



 
 
PHP Joomla! Silverlight Content Management Systems Content Management Systems Content Management Systems
 videos
 articles
 blogs
 comments
 downloads
sitemap

Newsletter

Get updates on Hiveminds services, articles and downloads by signing up for the newsletter.

Editor's choice

Some of the better articles, stories and tutorials found at Hiveminds.

Find more

Find more of Hiveminds articles, stories, tutorials and user comments by searching.




Picked links

Hand picked websites and articles from around the web that provide quality reading.

page top