[TYPO3-dev] How to get the extension typoscript configuration inside an eID script?

Ernesto Baschny [cron IT] ernst at cron-it.de
Tue Nov 17 08:28:26 CET 2009


Hi Peter,

Peter Klein schrieb:

> I usually use the type approch when working with FE/AJAX.
> This snippet was originally written for a BE/hook extension, where I had to 
> read the tt_news TS setup.
> And AFIK there's no way of accessing the Typoscript setup other than 
> creating a tmpl/tsfe object.

There is, just create a page with typeNum=123, disable headers etc (and
page renderer in v4.3) and then add your ajax handler as an USER_INT
plugin. You will have access to the whole TypoScript setup and it will
probably be much faster than your approach.

Cheers,
Ernesto


> "Ernesto Baschny [cron IT]" <ernst at cron-it.de> wrote in message 
> news:mailman.1.1258366809.4693.typo3-dev at lists.typo3.org...
>> Hi,
>>
>> Peter Klein schrieb:
>>
>>> If you don't need a full TSFE and only need to access some config
>>> vars/options, then you can do something like this:
>>>
>>> /* Classes required for creating a tmpl object */
>>> require_once(PATH_t3lib."class.t3lib_extobjbase.php");
>>> require_once(PATH_t3lib."class.t3lib_tsparser_ext.php");
>>> require_once(PATH_t3lib."class.t3lib_page.php");
>>>
>>>     $pageId = <SET THIS TO THE ID OF THE CURRENT PAGE>;
>>>
>>>    $tmpl = t3lib_div::makeInstance("t3lib_tsparser_ext");
>>>    $tmpl->tt_track = 0; // Do not log time-performance information
>>>    $tmpl->init();
>>>    // Gets the rootLine
>>>    $sys_page = t3lib_div::makeInstance("t3lib_pageSelect");
>>>    $rootLine = $sys_page->getRootLine($pageId);
>>>    // This generates the constants/config + hierarchy info for the 
>>> template.
>>>    $tmpl->runThroughTemplates($rootLine,0);
>>>    $tmpl->generateConfig();
>>>
>>>     // Example: Get the TS config for the tt_news plugin
>>>    $ttnewsConf = $tmpl->setup['plugin.']['tt_news.'];
>> I think this is much worse than just using a page type.
>> runThroughTemplates() is very "dumb" and low level: it generates lots of
>> SQL queries to fetch your typoscript from rootline, parses it, includes
>> external files, extension typoscript, and at the end generates the
>> needed array.
>>
>> In a full blown TSFE enrivonment you get all this with "one" query, as
>> it is already cached and can be served in no-time.
>>
>> So apart from being more code to write, it will most probably not be
>> more performant than loading an USER_INT on an ajax "page" cObject. Or
>> maybe your ajax call can even be cached as an USER object, which is then
>> even faster!




More information about the TYPO3-dev mailing list