Typo3 4.5, PiBase Extension, Ajax call with eID, 如何访问配置?
Typo3 4.5, PiBase Extension, Ajax Call with eID, how to access configuration?
所以我被分配了一个任务,这通常是微不足道的,但它必须在一个相当老的 Typo3-Website (4.5) 上工作。我对 Typo3 很陌生。
要进行 AJAX 调用,我发现我需要一个 eID,我自己的 class 文件,我发现了如何调用主函数等等。
现在,我在许多不同的位置有很多配置,我需要访问这些信息。
在 class.tx_as_es_pi1.php
中,function main($content, $conf)
有这个非常方便的参数 $conf
。这似乎是由一些 Typo3 魔法提供的。试图以某种方式模仿这种行为,我尝试了 this 答案,它为我提供了一些配置,使用这些行:
$conf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_ases_pi1.'];
var_dump($conf);
我得到这个结果:
'includeLibs' => string 'typo3conf/ext/as_es/pi1/class.tx_as_es_pi1.php' (length=46)
'userFunc' => string 'tx_ases_pi1->main' (length=17)
但是 Typoscript 对象浏览器显示了更多内容(包括我需要的):
[tx_ases_pi1] = USER_INT # TypoScript added by extension "as_es" # Setting as_es plugin TypoScript
[includeLibs] = typo3conf/ext/as_es/pi1/class.tx_as_es_pi1.php
[userFunc] = tx_ases_pi1->main
[config_template] = EXT:as_es/templates/results_elkwue.htm
[config_template_extended] = EXT:as_es/templates/extended_elkwue.htm
[config_searchaccesskey] = someAccessKey
[config_searchproxy] = someProxyUrl
[config_searchfilterurl] = soeSearchFilterUrl
[config_searchshowstat] = 1
[config_utf8decode] = 1
[config_maxtitlelength] = 50
[config_removefromtitle] = SomeString
[config_piwiktracking_host] = somePiwikHost
[config_piwiktracking_port] = 80
[config_piwiktracking_id] = SomeID
[config_fedebug_messages_search] = {$plugin.tx_ases_pi1.configuration.fedebug_messages_search}
所以,很明显,这里有些东西我不太明白。谁能指出我正确的方向?
[EDIT] 相关问题中的答案仅提供了部分配置数据,如上所示。我正在寻找有关如何检索其余数据的提示。
好的。我在 this old post.
中找到了答案
在 eID - class 中,添加此方法:
/**
* Initializes TSFE and sets $GLOBALS['TSFE'].
*
* @return void
*/
protected function initTSFE() {
$GLOBALS['TSFE'] = t3lib_div::makeInstance('tslib_fe',
$GLOBALS['TYPO3_CONF_VARS'], t3lib_div::_GP('id'), '');
$GLOBALS['TSFE']->connectToDB();
$GLOBALS['TSFE']->initFEuser();
$GLOBALS['TSFE']->checkAlternativeIdMethods();
$GLOBALS['TSFE']->determineId();
$GLOBALS['TSFE']->getCompressedTCarray();
$GLOBALS['TSFE']->initTemplate();
$GLOBALS['TSFE']->getConfigArray();
// Get linkVars, absRefPrefix, etc
TSpagegen::pagegenInit();
}
并在 main()
方法中调用它: $this->initTSFE();
。然后调用:
$conf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_ases_pi1.'];
var_dump($conf);
将输出完整列表。
我并不是说我真的会理解它...但是因为它可能会为其他人省去一些麻烦,所以我还是 post 正在使用它。
[编辑]
显然是这一行:
$GLOBALS['TSFE']->checkAlternativeIdMethods();
这很重要。删除它会导致问题中显示的短输出。
作为旁注:这些行:
$GLOBALS['TSFE']->initFEuser();
$GLOBALS['TSFE']->getCompressedTCarray();
TSpagegen::pagegenInit();
对我来说没有什么不同,所以我认为在我的情况下可以省略它们以加快速度。
我会把它们留在这里,因为它们可能会帮助其他人未来。
所以我被分配了一个任务,这通常是微不足道的,但它必须在一个相当老的 Typo3-Website (4.5) 上工作。我对 Typo3 很陌生。
要进行 AJAX 调用,我发现我需要一个 eID,我自己的 class 文件,我发现了如何调用主函数等等。
现在,我在许多不同的位置有很多配置,我需要访问这些信息。
在 class.tx_as_es_pi1.php
中,function main($content, $conf)
有这个非常方便的参数 $conf
。这似乎是由一些 Typo3 魔法提供的。试图以某种方式模仿这种行为,我尝试了 this 答案,它为我提供了一些配置,使用这些行:
$conf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_ases_pi1.'];
var_dump($conf);
我得到这个结果:
'includeLibs' => string 'typo3conf/ext/as_es/pi1/class.tx_as_es_pi1.php' (length=46)
'userFunc' => string 'tx_ases_pi1->main' (length=17)
但是 Typoscript 对象浏览器显示了更多内容(包括我需要的):
[tx_ases_pi1] = USER_INT # TypoScript added by extension "as_es" # Setting as_es plugin TypoScript
[includeLibs] = typo3conf/ext/as_es/pi1/class.tx_as_es_pi1.php
[userFunc] = tx_ases_pi1->main
[config_template] = EXT:as_es/templates/results_elkwue.htm
[config_template_extended] = EXT:as_es/templates/extended_elkwue.htm
[config_searchaccesskey] = someAccessKey
[config_searchproxy] = someProxyUrl
[config_searchfilterurl] = soeSearchFilterUrl
[config_searchshowstat] = 1
[config_utf8decode] = 1
[config_maxtitlelength] = 50
[config_removefromtitle] = SomeString
[config_piwiktracking_host] = somePiwikHost
[config_piwiktracking_port] = 80
[config_piwiktracking_id] = SomeID
[config_fedebug_messages_search] = {$plugin.tx_ases_pi1.configuration.fedebug_messages_search}
所以,很明显,这里有些东西我不太明白。谁能指出我正确的方向?
[EDIT] 相关问题中的答案仅提供了部分配置数据,如上所示。我正在寻找有关如何检索其余数据的提示。
好的。我在 this old post.
中找到了答案
在 eID - class 中,添加此方法:
/**
* Initializes TSFE and sets $GLOBALS['TSFE'].
*
* @return void
*/
protected function initTSFE() {
$GLOBALS['TSFE'] = t3lib_div::makeInstance('tslib_fe',
$GLOBALS['TYPO3_CONF_VARS'], t3lib_div::_GP('id'), '');
$GLOBALS['TSFE']->connectToDB();
$GLOBALS['TSFE']->initFEuser();
$GLOBALS['TSFE']->checkAlternativeIdMethods();
$GLOBALS['TSFE']->determineId();
$GLOBALS['TSFE']->getCompressedTCarray();
$GLOBALS['TSFE']->initTemplate();
$GLOBALS['TSFE']->getConfigArray();
// Get linkVars, absRefPrefix, etc
TSpagegen::pagegenInit();
}
并在 main()
方法中调用它: $this->initTSFE();
。然后调用:
$conf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_ases_pi1.'];
var_dump($conf);
将输出完整列表。
我并不是说我真的会理解它...但是因为它可能会为其他人省去一些麻烦,所以我还是 post 正在使用它。
[编辑]
显然是这一行:
$GLOBALS['TSFE']->checkAlternativeIdMethods();
这很重要。删除它会导致问题中显示的短输出。
作为旁注:这些行:
$GLOBALS['TSFE']->initFEuser();
$GLOBALS['TSFE']->getCompressedTCarray();
TSpagegen::pagegenInit();
对我来说没有什么不同,所以我认为在我的情况下可以省略它们以加快速度。
我会把它们留在这里,因为它们可能会帮助其他人未来。