Typo3 eID, how to access config

走远了吗. 提交于 2019-12-21 12:28:14

问题


I've just created an eID in Typo3. I can't figure out how to access the config data for my plugin from the Typo3 instance.

I've tried the code from the link but it doesn't want to work. I keep getting an exception "No TypoScript template found! " on the call " $TSFE->getConfigArray(); "

http://lists.typo3.org/pipermail/typo3-dev/2006-December/021392.html

Any ideas?

Thanks.


回答1:


In eID mode, only a small part of the regular TYPO3 frontend is loaded. Unfortunately TypoScript is not loaded. To still access the TypoScript configuration you need manually load the components it needs to do so. Unfortunately this can be a bit of a pain in the butt. So in some cases it might be easier to just load a page containing a single plugin that doesn't contain anything else (without headers etc.).

If you do want to load the TypoScript templates yourself, you can try something like the following:

require_once(PATH_tslib.'class.tslib_fe.php');
require_once(PATH_t3lib.'class.t3lib_userauth.php' );
require_once(PATH_tslib.'class.tslib_feuserauth.php');
require_once(PATH_t3lib.'class.t3lib_cs.php');
require_once(PATH_tslib.'class.tslib_content.php') ;
require_once(PATH_t3lib.'class.t3lib_tstemplate.php');
require_once(PATH_t3lib.'class.t3lib_page.php');

$TSFEclassName = t3lib_div::makeInstanceClassName('tslib_fe');
$id = isset($HTTP_GET_VARS['id'])?$HTTP_GET_VARS['id']:0;

$GLOBALS['TSFE'] = new $TSFEclassName($TYPO3_CONF_VARS, $id, '0', 1, '','','','');
$GLOBALS['TSFE']->connectToMySQL();
$GLOBALS['TSFE']->initFEuser();
$GLOBALS['TSFE']->fetch_the_id();
$GLOBALS['TSFE']->getPageAndRootline();
$GLOBALS['TSFE']->initTemplate();
$GLOBALS['TSFE']->tmpl->getFileName_backPath = PATH_site;
$GLOBALS['TSFE']->forceTemplateParsing = 1;
$GLOBALS['TSFE']->getConfigArray();

$cObj = t3lib_div::makeInstance('tslib_cObj');

This initializes the TSFE and cObj but is also used to load and parse the TypoScript templates. You might need to make some modifications to (probably kick some things out)

The code came from one of the comments on the following blog post: http://sebastiaandejonge.com/blog/articles/2010/september/21/bringing-ajax-to-your-frontend-plugins/

Good luck!



来源:https://stackoverflow.com/questions/7835380/typo3-eid-how-to-access-config

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!