[Typo3-dev] PHP syntax
Kraft Bernhard
kraftb at gmx.net
Sun Sep 4 16:21:52 CEST 2005
Søren Vedel wrote:
> In pi1/locallang.php I have this:
>
> $LOCAL_LANG = Array (
> "default" => Array (
> "listFieldHeader_type" => "Type",
> "listFieldHeader_city" => "City",
> ...
>
>
> In locallang_db.php I have this:
>
> $LOCAL_LANG = Array (
> "default" => Array (
> "tx_telexadresses_filiaisfranquias" => "Filiais and Franquias",
> "tx_telexadresses_filiaisfranquias.type.I.0" => "Filiais",
> "tx_telexadresses_filiaisfranquias.type.I.1" => "Franquias",
> "tx_telexadresses_filiaisfranquias.type" => "Type",
> ...
>
>> you should retrieve those values by using $this->pi_getLL('label_1')
>> or label_2 label_3 ...
>>
>> the keys 'label_1' must get defined in the pi1/locallang.php file ...
>>
>> so your extension also supports multiple languages ...
>
> I know!
>
> I want to retrieve:
> "tx_telexadresses_filiaisfranquias.type.I.0" => "Filiais",
> when type is "0" and,
> "tx_telexadresses_filiaisfranquias.type.I.1" => "Franquias",
> when type is "1".
>
> When I output this in singleview:
>
> <td valign="top">
> <p>'.$this->getFieldContent("type").'</p>
> </td>
Either you do:
<p>'.$this->pi_getLL('tx_telexadresses_filiaisfranquaias.type.I.'.$this->getFieldContent("type")).'</p>
Or you insert the following code into the "switch" statement of the method "getFieldContent"
then getFieldContent('type') will return the correct value directly:
----------------
switch ($field) {
...
case 'type':
return $this->pi_getLL('tx_telexadresses_filiaisfranquaias.type.I.'.$this->internal['currentRow']['type']);
....
}
---------------
But for both of those you will have to add (copy):
> "tx_telexadresses_filiaisfranquias.type.I.0" => "Filiais",
> "tx_telexadresses_filiaisfranquias.type.I.1" => "Franquias",
from: my_ext/locallang_db.php
to: my_ext/pi1/locallang.php
It would also be possible by including the my_ext/locallang_db.php directly but this is rather
complicated than just copying the lines ... and I think you prefer the simple solution :)
greets,
Bernhard
--
----------------------------------------------------------------------
"Freiheit ist immer auch die Freiheit des Andersdenkenden"
Rosa Luxemburg, 1871 - 1919
----------------------------------------------------------------------
More information about the TYPO3-dev
mailing list