Revision: 48264
Updated Code
at June 28, 2011 17:11 by pogosheep
Updated Code
/** * 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(); $tsFile = fopen($tsFileName, "r"); $tsParser->parse(fread($tsFile, filesize($tsFileName))); return Tx_Extbase_Utility_TypoScript::convertTypoScriptArrayToPlainArray($tsParser->setup); }
Revision: 48263
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 28, 2011 00:46 by pogosheep
Initial Code
require_once t3lib_div::getFileAbsFileName("t3lib/class.t3lib_tsparser.php", false, false); $tsFileName = t3lib_div::getFileAbsFileName("fileadmin/typoscript/yourfile.ts", false, false); $tsParser = new t3lib_TSparser(); $tsFile = fopen($tsFileName, "r"); $tsParser->parse(fread($tsFile,filesize($tsFileName))); var_dump($tsParser->setup);
Initial URL
http://wiki.typo3.org/User:Layne_obserdia/Backend
Initial Description
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.
Initial Title
Get TypoScript configuration everywhere
Initial Tags
Initial Language
PHP