[TYPO3-dev] How do I access Typoscript Setup from a BE Module?

Oliver Klee typo3-german-02 at oliverklee.de
Thu Apr 29 14:38:18 CEST 2010


Hi,

Peter Klein schrieb:
> Im working on an extension where I have a BE module which needs to
> access the Typoscript setup  (Not the Page TSconfig) of a selected
> page.
> 
> So I don't need a full TSFE object, just the setup data.

My code for this looks like this (for the setup for a certain extension):

/**
 * Retrieves the configuration (TS setup) of the page with the PID provided
 * as the parameter $pageId.
 *
 * Only the configuration for the current extension key will be retrieved.
 * For example, if the extension key is "foo", the TS setup for plugin.
 * tx_foo will be retrieved.
 *
 * @param integer page ID of the page for which the configuration
 *                should be retrieved, must be > 0
 *
 * @return array configuration array of the requested page for the
 *               current extension key
 */
protected function retrievePageConfig($pageId) {
	$template = t3lib_div::makeInstance('t3lib_TStemplate');
	// Disables the logging of time-performance information.
	$template->tt_track = 0;
	$template->init();

	$sys_page = t3lib_div::makeInstance('t3lib_pageSelect');

	// Gets the root line.
	// Finds the selected page in the BE exactly as in t3lib_SCbase::init().
	$rootline = $sys_page->getRootLine($pageId);

	// Generates the constants/config and hierarchy info for the template.
	$template->runThroughTemplates($rootline, 0);
	$template->generateConfig();

	if (isset($template->setup['plugin.']['tx_'.$this->extKey.'.'])) {
		$result = $template->setup['plugin.']['tx_' . $this->extKey . '.'];
	} else {
		$result = array();
	}

	return $result;
}


Oli
-- 
Certified TYPO3 Integrator | TYPO3 Security Team Member




More information about the TYPO3-dev mailing list