Home Документация Уроци How to use different templates?
How to use different templates? ПДФ Печат Е-мейл
Написано от Ivo Apostolov   
Сряда, 25 Април 2007 23:01
NO TRANSLATION AVAILABLE

See JOOMFISH 1.7 Tips & tricks in the Joomla! Forums.

Taken from that post:

TIP 1 - HOW TO LOAD A CSS DEPENDING OF THE LANGUAGE FRONT-END SWITCH ?

1. Add the following tag in your template index.php file:

<link href="<?php echo $mosConfig_live_site;?>/templates/
YOUR TEMPLATE NAME/css/<?php echo $mosConfig_lang;?>.css" rel="stylesheet" type="text/css"/>

This will write CSS files, depending of the selected language: english.css, spanish.css, german.css, italian.css, portuguese.css, etc...

2. If your defaut joomla language is set to english, then leave english.css empty & place it in the /templates/YOUR TEMPLATE NAME/css/ directory. Customize the other css files according to your needs. The most natural use is to change the path to an image file:

#whatever { 
background-image: url('/"../images/header_german.gif"');
for the german.css file
}
#whatever {
background-image: url('/"../images/header_spanish.gif"');
for the spanish.css file
}

Place the produced CSS files into the /templates/YOUR TEMPLATE NAME/css/ directory

How to select a template based on the language front-end switch?

The most easy solution is to add the following lines in your index.php

  // gets template for page 
$cur_template = $mainframe->getTemplate();
// add this
if( $mosConfig_multilingual_support ) {
$cur_template .= "-". $iso_client_lang;
}
else {
$cur_template .= "-en";
}

Now every template would be named with his standard name plus a "-en" or "-de" or anything else.

 

3 Comments

  1. Hello David, I have the problem with the switching templates function. it will not work with the script above in joomla 1.5.x . Can you descripe it a bit further ( the template function not css.) many thanks
  2. Thanks
  3. If you are using Joomla 1.5.x and want to switch style sheets or templates this method will not work as the variable $mosConfig_lang is not valid to joomla 1.5.x. Instead do the following: predifne the following early in your template: $config=&JFactory::getConfig(); $lang=$config->getValue('language'); then use the variable $lang to point to the style sheet you would like to include: Ex: /templates/YOURTEMPLATE/css/.css" type="text/css" /> Then in my case I had to create en-GB.css for English es-ES.css for spanish etc etc

Add Comment

Joom!Fish 2.0 RC download

Избрани сътрудници

От екипа на Джум!Фиш (Алекс, Герайнт, Иво & Робин), голямо благодарим към цялата Джум!Фиш общност. Специални благодарност за тестването, предложенията, преводите и модерирането към:

  • Томи Уай за сладкото лого
  • Бернхард, Майкъл, Люк, Оливие, Робин, Руне, Акаравут
  • Хари (Тасу) за модерирането

Recommended Reading

Buy Joomla! 1.5 with directshopper