/ Published in: PHP
I hate to configure everything twice or more often. So I use typoscript to configure everything at one place. To get this configuration in my php-scripts (perhaps a hook) I use this little Code:
First you need to include the typoscript parser. The you have to read your typoscript file. Then you can parse the file content.
$tsParser->setup contains the parsed typoscript.
First you need to include the typoscript parser. The you have to read your typoscript file. Then you can parse the file content.
$tsParser->setup contains the parsed typoscript.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * Parses the typoscript of an sys_template. * NOTICE: Constants won't be solved. * * @param integer $typoScriptUid The uid of the sys_template. * @return array The typoscript confirugation, without the ".". * * @author Daniel Siepmann < [email protected] > */ static function getTypoScriptFromDb($typoScriptUid) { require_once t3lib_div::getFileAbsFileName("t3lib/class.t3lib_tsparser.php", false, false); require_once t3lib_div::getFileAbsFileName("typo3/sysext/extbase/Classes/Utility/TypoScript.php", false, false); $rawTypoScript = $GLOBALS["TYPO3_DB"]->exec_SELECTgetRows( " config ", " sys_template ", " uid = " . $typoScriptUid ); $tsParser = new t3lib_TSparser(); $tsParser->parse(t3lib_TSparser::checkIncludeLines($rawTypoScript[0]["config"])); return Tx_Extbase_Utility_TypoScript::convertTypoScriptArrayToPlainArray($tsParser->setup); } /** * Parses a typoscript file. * NOTICE: Constants and includes won't be solved. * * @param string $file The file name of the file you want to parse. With complete parse like "fileadmin/typoscript/setup.ts". * @return array The typoscript confirugation, without the ".". * * @author Daniel Siepmann < [email protected] > */ static function getTypoScriptFromFile($file) { require_once t3lib_div::getFileAbsFileName("t3lib/class.t3lib_tsparser.php", false, false); require_once t3lib_div::getFileAbsFileName("typo3/sysext/extbase/Classes/Utility/TypoScript.php", false, false); $tsFileName = t3lib_div::getFileAbsFileName($file, false, false); $tsParser = new t3lib_TSparser(); "r"); return Tx_Extbase_Utility_TypoScript::convertTypoScriptArrayToPlainArray($tsParser->setup); }
URL: http://wiki.typo3.org/User:Layne_obserdia/Backend