Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
TYPO3-在外部php文件中获取当前语言_Typo3 - Fatal编程技术网

TYPO3-在外部php文件中获取当前语言

TYPO3-在外部php文件中获取当前语言,typo3,Typo3,我是TYPO3:)的初学者,我想在外部php文件中获取当前语言 我该怎么做 非常感谢。如果您有一个TSFE实例,您可以通过$GLOBALS['TSFE']->sys\u language\u uid访问sys\u language\u uid通常情况下,在typo3中,L总是用作语言参数$_获取['L']获取当前语言的最佳方式始终是: $GLOBALS['TSFE']->sys_language_uid 或 基于此,您可以获得当前的语言id,并可以为此提供条件 获取Typo3 10.

我是TYPO3:)的初学者,我想在外部php文件中获取当前语言

我该怎么做


非常感谢。

如果您有一个TSFE实例,您可以通过
$GLOBALS['TSFE']->sys\u language\u uid
访问
sys\u language\u uid
通常情况下,在typo3中,L总是用作语言参数$_获取['L']

获取当前语言的最佳方式始终是:

$GLOBALS['TSFE']->sys_language_uid  

基于此,您可以获得当前的语言id,并可以为此提供条件

获取Typo3 10.x版本中的当前语言

$context = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Context\Context::class);
$langId = $context->getPropertyFromAspect('language', 'id');

对于V9,
$GLOBALS['TSFE']->sys\u language\u uid
已被弃用,建议使用语言特性

例如:

$languageAspect = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Context\Context::class)->getAspect('language');
$sys_language_uid = $languageAspect->getId();
打字3 9+

$context = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Context\Context::class);

// The requested language of the current page as integer (uid)
$currentLanguageUid = $context->getPropertyFromAspect('language', 'id');

我不需要包含任何文件就可以使用它?我得到一个错误:注意:未定义的索引:TSFE在………好吧,如果文件被包括在您的TYPO3中作为用户或用户INT,而不是。你如何包括你的档案?或者它运行在TYPO3上下文之外?谢谢,它运行在TYPO3上下文之外自从TYPO3 9以来,使用语言方面:
$context = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Context\Context::class);

// The requested language of the current page as integer (uid)
$currentLanguageUid = $context->getPropertyFromAspect('language', 'id');