[Typo3] Typoscript to detect which language is selected

Francois Suter fsuter at cobweb.ch
Wed Jun 8 14:20:40 CEST 2005


> Hello,

Hi,

> I have a problem about language detection in Typoscript. I have a web 
> site
> in three languages and I would like to set up differently the Tamplate
> depending in which language is displayed the page.
>
> Does anybody now how to test the current language and than write a 
> condition
> in which the set up is made in accordance with the current language ?

Languages are tested using the global variable "L". Here is an example 
test:

[globalVar = GP:L = 0]
   config.sys_language_uid = 0
   config.language = fr
[globalVar = GP:L = 2]
   config.sys_language_uid = 2
   config.language = en
[GLOBAL]

> temp.menuhaut = COA
> temp.menuhaut {
>   40 = TEXT
>   40.data = field:uid
>   40.wrap = <span class="menu_haut_actif">&nbsp;<a
> href="?id=|&L=0">Fr</a>&nbsp;</span>
>   50 = TEXT
>   50.data = field:uid
>   50.wrap = <span class="menu_haut_actif">&nbsp;<a
> href="?id=|&L=2">De</a>&nbsp;</span>
>   60 = TEXT
>   60.data = field:uid
>   60.wrap = <span class="menu_haut_actif">&nbsp;<a
> href="?id=|&L=3">En</a>&nbsp;</span>
> }

Conditions like the one shown above cannot be used inside braces. This 
means you will have to prepare your menu in several steps. Something 
along those lines:

[globalVar = GP:L = 0]
	temp.french = TEXT
	temp.french.value = Français
[globalVar = GP:L = 2]
	temp.french = TEXT
	temp.french.value = French
[GLOBAL]

temp.menuhaut = COA
temp.menuhaut {
	40 < temp.french
}

Hope this helps

François Suter
Directeur technique
-----------------------------------------------------
Cobweb Development Sàrl
www.cobweb.ch
-----------------------------------------------------



More information about the TYPO3-english mailing list