I was having some troubles configuring my frontpage as I liked. After messing around with the $page==0 and $is_front Variables in phptemplate and testing several php-Hacks directly in the page.tpl.php file I found a solution to get phptemplate's $is_front Variable running correctly:
phptemplate.engine, lines 79 and 80 read as follows:
if (drupal_get_path_alias($_GET['q']) == variable_get('site_frontpage', 'node')) {
$vars['is_front'] = true;
}The problem is, that the comparison fails, because the language-ID (e.g. 'en') is missing in front of your front page's name. If these lines are replaced by
$currentpage = drupal_get_path_alias($_GET['q']);
$frontpage = variable_get('site_frontpage', 'node');
if ($currentpage == $frontpage or $currentpage==$GLOBALS['locale'].'/'.$frontpage) {
$vars['is_front'] = true;
}the URL of the current page is compared to e.g. 'en/node' AND'node' and so the compariso should get correct results, even if you enabled clean URLs and use the i18n module with option 'Front page: Language dependent'.
Hope this is helpful for some of you. Please comment and improve.
Bernhard
Comments
i18n frontpage in 4.7/phptemplate?
I'm not sure if my problem is related to this - I've installed the CVS version of i18n with 4.7, but when i go to the frontpage, the blocks that are configured to show up on that page do not show up. I'm using a phptemplate theme (friendselectric) - I've tried looking through the phptemplate.engine for 4.7, but I don't see similar code as is displayed above. Any ideas on what I should try in order to correct this?
thanks!
i18n and front page in different languages for 4.7.2
I've a problem with my front page and the i18n (languages are italian and english):
I've created a page-front_it.tpl.php and a page-front_eng.tpl.php in my custom theme (they have to look different from the rest of the site); the problem is how can I switch from the italian version to the english version of the front page.
In page.tpl.php I've put this code at the top of the file (in php tags):
if ($is_front) {
include('page-front_it.tpl.php');
return;
}
(I haven't yet try to include 'page-front_eng.tpl.php')
but the front page doesn't work if the url is with the /?q=it/node (for italian) and the /?q=eng/node (for english). It works (for the italian one) only if the url is like www.example.com
How can I configure drupal to switch languages in custom front pages, from www.example.com/?q=it/node to www.example.com/?q=eng/node?
Thanks and sorry if I've posted not in the right place