Hi,
I figured finally out also how to assign for each language selected a different template... So,
if you want to create a site with a totally different template for each language selected, then you
need to call the templates by using PHP and if conditions in a "fake template". The logic here
is that you must have already defined a default template in your database; in the index.php file
of this default template you must also set the right conditions like this:
If the language selected is English include once the file english-template/index.php
\/ (If the answer is NO then continue
\/ with the else statement)
\/
If the language selected is German include once the file german-template/index.php
\/ (If the answer is NO then continue
\/ with the else statement)
\/
If the language selected is French include once the file french- template/index.php
\/
\/
\/
.................
In other words, the fake template will have only this (index.php code) inside:
Code:
<?php
$config=&JFactory::getConfig();
$lang=$config->getValue('language');
if ($lang=="en-GB")
include_once("english-template/index.php");
else
if ($lang=="de-DE")
include_once("german-template/index.php");
else
if ($lang=="fr-FR")
include_once("french-template/index.php");
....
?>
As example, if we use for the english language the beez template, for the german language the
rhuk_milkyway template, and for the french language the ja_purity template, then your fake
template will just say this:
Code:
<?php
$config=&JFactory::getConfig();
$lang=$config->getValue('language');
if ($lang=="en-GB")
include_once("beez/index.php");
else
if ($lang=="de-DE")
include_once("rhuk_milkyway/index.php");
else
if ($lang=="fr-FR")
include_once("ja_purity/index.php");
?>
In this example, to be more analytical, I have created in the htdocs/template a template file (e.g.
with the name fake-template) and copied in this template file the whole template files of the above three templates.
So when you choose as default template the fake-template, then your default template will be
beez, and when you choose then the german language, the template will change to rhuk_milkyway and when you select french the template turns to ja_purity. Of course, in this
example, in the two of this templates you can select parameters in the back end, therefore we
have to change the index.php code of this templates accordingly, since the parameters can only
be called if the specific template is active as a default one in joomla (but obviously our default
template remains always the fake-template). Furthermore you must correct also the path for the
css etc. files (except if you have this templates also as separate ones in your templates file, then
the css ect. files can be loaded directly from there). For the rhuk_milkyway the code correction is
the following:
This code in the index.php:
Code:
...
<head>
<jdoc:include type="head" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/system.css"
type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/general.css"
type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/css/template.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/css/<?php
echo $this->params->get('colorVariation'); ?>.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/css/<?php
echo $this->params->get('backgroundVariation'); ?>_bg.css" type="text/css" />
<!--[if lte IE 6]>
<link href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/ieonly.css" rel="stylesheet" type="text/css" />
<![endif]-->
<?php if($this->direction == 'rtl') : ?>
<link href="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/css/template_rtl.css" rel="stylesheet" type="text/css" />
<?php endif; ?>
</head>
<body id="page_bg" class="color_<?php echo $this->params->get('colorVariation'); ?> bg_<?php
echo $this->params->get('backgroundVariation'); ?> width_<?php echo $this->params->get
('widthStyle'); ?>">
...
must be changed to this code (if you want to choose the white variation and the template width
medium (i.e. 950px):
Code:
...
<head>
<jdoc:include type="head" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/system.css"
type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/general.css"
type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/fake-template/rhuk_milkyway/css/template.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/fake-template/rhuk_milkyway/css/blue.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/fake-template/rhuk_milkyway/css/blue_bg.css" type="text/css" />
<!--[if lte IE 6]>
<link href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/fake-template/css/ieonly.css" rel="stylesheet" type="text/css" />
<![endif]-->
<?php if($this->direction == 'rtl') : ?>
<link href="<?php echo $this->baseurl ?>/templates/fake-template/rhuk_milkyway/css/template_rtl.css" rel="stylesheet" type="text/css" />
<?php endif; ?>
</head>
<body id="page_bg" class="medium_small">
...
I hope that the above codes will give an idea on how to go about in changing the templates for
the language each time in use...
Regards, Styl
PS: To my earlier post about the "if blocks" I have to add that it is obvious that someone can use
"and" & "or" statements to do more complicated stuff, even integrate a whole template... For
example, you can write the if blocks like this:
1)
Code:
<?php if($lang == 'de-DE or da-DK or fr-FR or ru-RU'): // You can do stuff which will appear only in this four languages: German, Danish, French and Russian ?>
or like this
2)
Code:
<?php if($lang == 'de-De' and $pageview != 'frontpage' and $pageoption == 'com_comprofiler'):
?>: // You can do stuff which
will appear only in the German language selection and only in the interios pages, and if it is
community builder particular component type page ?>
or
3) if you want to have a collapsible e.g. left column which should show only if the selected
language is English, then for example in the template ja_purity the code should be modified to:
Code:
<?php if ($this->countModules('right') and $lang == 'en-GB'): ?>
<!-- BEGIN: RIGHT COLUMN -->
<div id="ja-col2">
<jdoc:include type="modules" name="right" style="jarounded" />
</div><br />
<!-- END: RIGHT COLUMN -->
<?php endif; ?>
4) you can even integrate a whole template in the if blocks (if you don't want to use a fake
template), like this for the english, german and other languages:
Code:
...
<head>
...
<?php
if ($this->language=="en-GB"): ?>
<link rel="stylesheet" href="/<?php echo $this->baseurl ?>/<?php echo $this->template ?>/css/template_en.css" type="text/css" />
<?php else
if ($this->language=="de-DE"): ?>
<link rel="stylesheet" href="/<?php echo $this->baseurl ?>/<?php echo $this->template ?>/css/template_de.css" type="text/css" />
<?php else
if ($this->language=="..-.."): ?>
<link rel="stylesheet" href="/<?php echo $this->baseurl ?>/<?php echo $this->template ?>/css/template_OTHERlanguage.css" type="text/css" />
<?php } endif; ?>
...
</head>
<body>
...
<?php if ($lang == 'en-GB': //You can put the php body code of your template for the english
language which has the template_en.css stylesheet
?>
<?php if ($lang == 'de-DE': //You can put the php body code of your template for the german
language which has the template_de.css stylesheet
?>
<?php if ($lang == '..-..': //You can put the php body code of your template for the .. language
which has the template_OTHERlanguage.css stylesheet
?>
...
</body>
...