[TYPO3-dev] parse typoscript setup and constants for eID script

Simon Schaufelberger (Schaufi) simonschaufi at jesus.de
Fri Nov 11 17:59:35 CET 2011


just in case somebody is interested in the solution, here is the working 
code:

$GLOBALS['TSFE']->config['config'] = array();
$GLOBALS['TSFE']->getConfigArray();
$GLOBALS['TSFE']->renderCharset = 'utf-8';
$GLOBALS['TSFE']->fe_user = tslib_eidtools::initFeUser();
# the next 3 lines are neccessary for the typolink function to work 
(http://www.typo3.net/forum/beitraege/diverse_fragen/81749/)
$GLOBALS['TSFE']->tmpl = t3lib_div::makeInstance('t3lib_TStemplate');
$GLOBALS['TSFE']->initTemplate();
$GLOBALS['TSFE']->sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
# required for enablefields
$GLOBALS['TSFE']->cObj = t3lib_div::makeInstance('tslib_cObj');

//Typoscript parsing
$typoscriptInclude = '<INCLUDE_TYPOSCRIPT: 
source="FILE:EXT:extension/Configuration/TypoScript/setup.txt">
plugin.tx_community.persistence.storagePid = 29';

# http://typo3blogger.de/config-parsen-mit-t3lib_tsparser/
require_once(PATH_t3lib.'class.t3lib_tsparser.php');
$config = t3lib_div::makeInstance('t3lib_TSparser'); /* @var $config 
t3lib_TSparser */
$configTS = $config->checkIncludeLines($typoscriptInclude);

//Constants parsing
$constantsInclude = '<INCLUDE_TYPOSCRIPT: 
source="FILE:EXT:extension/Configuration/TypoScript/constants.txt">';
$constants = t3lib_div::makeInstance('t3lib_TSparser'); /* @var 
$constants t3lib_TSparser */
$constantsTS = $constants->checkIncludeLines($constantsInclude);
$constants->parse($constantsTS);

$GLOBALS['TSFE']->tmpl->flattenSetup($constants->setup, '', '');

//substitute constants in config ts
$all = $GLOBALS['TSFE']->tmpl->substituteConstants($configTS);

// Finally parse the Setup field TypoScript code (where constants are 
now substituted)
$config->parse($all);

$GLOBALS['TSFE']->tmpl->setup = $config->setup;

Regards, Schaufi

Am 09.11.2011 12:32, schrieb Simon Schaufelberger:
> Thank you very much, this was the correct answer to my question ;)
>
> Am 09.11.2011 12:26, schrieb Pierre Dudoret:
>> t3lib_TStemplate->substituteConstants, called
>> in t3lib_TStemplate->generateConfig
>>
>> 2011/11/9 Simon Schaufelberger<schaufelREMOVE-MEberger at punkt.de>
>>
>>> Hi,
>>> asking this question again:
>>> where is the place in the core where the constants are replaced?
>>>
>>> Am 08.11.2011 18:10, schrieb Oliver Klee:
>>>> Hi,
>>>>
>>>> Am 08.11.2011 17:43, schrieb Simon Schaufelberger:
>>>>> In my case i call an extbase plugin via ajax and therefor i don't need
>>>>> any page related typoscript but only the typoscript (and constants) fot
>>>>> that extension so i am independent of any page.
>>>>
>>>> This won't work - TS always needs a page to reside on. (You could parse
>>>> the TS setup somehow, but then you probably don't get the magic of
>>>> having the constants replaced etc.).
>>>>
>>>> I recommend using settings in the EM instead.
>>>>
>>>>
>>>> Oli
>>>
>>> --
>>> Kind regards,
>>>
>>> Schaufi from punkt.de
>>> _______________________________________________
>>> TYPO3-dev mailing list
>>> TYPO3-dev at lists.typo3.org
>>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev
>>>
>



More information about the TYPO3-dev mailing list