[Typo3-dev] getting values from locallang_db.php for frontend output
Thorsten Kahler
thorsten.kahler at dkd.de
Tue Jun 21 20:28:22 CEST 2005
Hi Joey,
t3lib_div (and some other t3lib classes and objects, e.g.
$GLOBALS['TYPO3_DB']) are available in the FE, of course, since they're
needed there also.
Back to you problem:
tslib_fe::readLLfile() uses t3lib_div::getFileAbsFileName() to get the
real filename. You can use tslib_fe::readLLfile() the way you want to, but
you have to put the extension key after "EXT:". Something like
$labels =
$GLOBALS['TSFE']->readLLfile('EXT:some_extension/locallang_db.php');
should do.
But in your OP you asked for the "preferrable way" to include LL labels.
When I looked at tslib_fe I also found (just before readLLfile()) the
function tslib_fe::sL(). It does the same for FE as language::sL() does
for BE. $GLOBALS['LANG'] is one of the classes/objects that's not
available in FE, but some of it's functionality is realized in tslib_fe.
The syntax for the label key is similar to the syntax used for "title" in
the "ctrl" section of $TCA [1]. The contents of every file that's opened
by tslib_fe::sL() are cached so there's no performance issue. Additionaly
this function also takes care of charset conversion.
IMHO the "preferrable way" is to leave the label management to the core
and use tslib_fe::sL() like
$label =
$GLOBALS['TSFE']->sL('LLL:EXT:some_extension/locallang_db.php:label_key');
Regards
Thorsten
PS: I should keep this in mind for my extensions, too ;-)
[1]
http://typo3.org/documentation/document-library/doc_core_api/ctrl_section/
On Tue, 21 Jun 2005 17:07:08 +0200, JoH <info at cybercraft.de> wrote:
>>
>> if u use it in FE make sure to do a
>> 'require_once(t3lib . 'class.t3lib_div.php'); or something like this.
>> t3lib_div is afaik not available in FE by default?
>
> Well - since this line works
> $this->getVars = t3lib_div::_GET();
> class.t3lib_div.php should be available.
>
> And I already got a working function call with:
> $labels = $GLOBALS['TSFE']->readLLfile('EXT:locallang_db.php');
>
> But there must still be something wrong with the syntax for the file/path
> since the result is an empty array although there is something defined in
> locallang_db.php
>
> Joey
>
--
No Subject - No Realname - No Service!
Respect the List/Newsgroup Rules!
>> http://typo3.org/1438.0.html <<
It's not a bug - it's an undesired feature.
More information about the TYPO3-dev
mailing list