Posted by beckyjohnson on April 9, 2009 at 6:42pm
We are adding Japanese to our website with English as our default language. We want to style our Japanese front page with different graphics that have the text in the graphics in Japanese. So right now, I guess our set up is showing the Japanese front page as http://www.mysite.com/ja . My question is how would be template out a new page for the japanese home page? Can we have a template called front-page-japanese.tpl.php? OR, can you not have different page templates for different languages?
Also, I read the page in the drupal handbook about adding the multilanguage variables to the settings page but after I add them, I not sure what to do...
Thanks,
Becky
Comments
Drupal version ?
Hi
You did not mentioned drupal version you are using
so if you use drupal 6 have a look here http://drupal.org/node/190815
and here is a code sample how to set your own tpl file http://drupal.org/node/190815#comment-1113949, just check the language (the url) and set the page-front-js.tpl.php as the template for the front page
about your second question , the multilang variables are used in the settings forms for that language (and don;t overwrite the other lang) , so when you are in site/en/admin/.... and set the front page for english , when you go to site/jp/admin/... you can set the var for that lang
good luck
Avior
Http://dev-art/english
Awesome. Thank you so much.
Awesome. Thank you so much. I will reply back if i have problems but thanks! Also, yes, I'm using Drupal 6.
I tried to create my own tpl
I tried to create my own tpl file and modified the code from the link you sent me, for my own purposes. Is this right? It didn't work for me actually. I loaded up the page-front-js.tpl.php file too, so I think i have poor knowledge of drupal programing.
Please take a look:
<?php
/**
* Override or insert variables into the node templates.
<em>
</em>@param $vars
<em>An array of variables to pass to the theme template.
</em> @param $hook
* The name of the template being rendered ("node" in this case.)
*/
function phptemplate_preprocess_node(&$vars, $hook) {
$page = $vars['page'];
$vars['template_file'] = 'page-'.'front-'. ja;
}
?>
Thank you, Becky
Ps. I don't know why but there are
<em>
tags showing up in the preview of this comment, so please ignore them if they show up on my posted comment.[UPDATE]: the em tags were little gremlin characters. I removed them and tried it in my template file again and still no luck.
Thanks,
Becky
Try this to get template
Try this to get template page-front-japanese.tpl.php for Japanese only:
function phptemplate_preprocess_page(&$vars, $hook) {
if($vars['is_front'] && $vars['language']->language == 'ja') {
$vars['template_file'] = 'page-front-japanese';
}
}
or if you wish to have two templates for Japanese and English:
function phptemplate_preprocess_node(&$vars, $hook) {
if($vars['is_front']) {
$language = $vars['language']->language;
$vars['template_file'] = 'page-front-'. $language;
}
}
which will produce page-front-ja.tpl.php and page-front-en.tpl.php
You were using hook_preprocess_node before - this does not allow modifying page templates, it is meant for node templates
What about node templates?
Will you need some similar code to get diferent templates for multilanguage sites?
For my default language, the systems uses node-type.tpl.php, bu for the other language, system always ignores that ovrride and uses the core node.tpl.php.
TY
Oh my gosh, thanks! That
Oh my gosh, thanks! That worked like a dream. Yesterday after thinking about it, I realized that hook_preprocess_node wasn't the right thing to use but I had no idea how to find the right code to use. I was looking a the drupal api website but there are so many functions there that I didn't know what to pick. How do you learn this stuff? Where is a good starting point to really meaningfully leaning how to program for drupal?
Thanks!
Becky
for D7 ?
for D7 ?
Persian support of drupal : http://www.irdrupal.com