TYPO3 9.5 为所有后端页面包含一个 TypoScript 文件
TYPO3 9.5 Include a TypoScript File for all Backend pages
我确实编写了一个带有后端模块的名为 'locationgallery' 的 Typo3 扩展。此后端模块应使用以下 TypoScript 配置。
module.tx_locationgallery_web_locationgallerylocationgallerybe {
view {
templateRootPaths.0 = EXT:locationgallery/Resources/Private/Backend/Templates/
partialRootPaths.0 = EXT:locationgallery/Resources/Private/Backend/Partials/
layoutRootPaths.0 = EXT:locationgallery/Resources/Private/Backend/Layouts/
}
}
如果我现在包含 'locationgallery' 的静态模板,它是通过 ExtensionManagementUtility::addStaticFile
添加的,那么在包含此模板的每个页面上一切正常。
我的问题是,我收到错误消息
Sorry, the requested view was not found.
The technical reason is: No template was found. ...
如果我 select 页面树中的页面不包含静态模板。
我现在的问题是我不想在根页面中包含静态模板,但是'locationgallery'的后端模块需要在所有页面上都可用。
我确实尝试使用 ExtensionManagementUtility::addPageTSConfig
包含配置的相应部分,用于将 TSConfig 添加到 $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig']
变量。但是在视图试图找到模板之前,这个 Typoscript 不会被解释。 (例如,据我所知,在这个 运行 期间它根本没有被解释,因为我发现只有 TemplateService::mergeConstantsFromPageTSconfig
和 TypoScriptFrontendController::getPagesTSconfig
指的是 $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig']
。)
我发现 powermail
使用 ext_typoscript_setup.typoscript, but this is deprecated according to https://forge.typo3.org/issues/52364 存档了我想要的内容。
此方法的另一个缺点是 'ext_typoscript_setup.typoscript' 的解释独立于后端和前端模式。
我想知道是否有任何未弃用的方法来为 Typo3 中的任何后端 运行 包含一些 TypoScript。
感谢您的任何建议。
您可以将您的 TS 设置拆分为多个文件以分隔包含内容。
在Configuration/TCA/Overrides/sys_template.php
中添加以下方法
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
'your_ext_key',
'Configuration/TypoScript/backend_or_however_you_call_it.typoscript',
'Your label'
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
'your_ext_key',
'Configuration/TypoScript/frontendend_or_however_you_call_it.typoscript',
'Your label'
);
我确实编写了一个带有后端模块的名为 'locationgallery' 的 Typo3 扩展。此后端模块应使用以下 TypoScript 配置。
module.tx_locationgallery_web_locationgallerylocationgallerybe {
view {
templateRootPaths.0 = EXT:locationgallery/Resources/Private/Backend/Templates/
partialRootPaths.0 = EXT:locationgallery/Resources/Private/Backend/Partials/
layoutRootPaths.0 = EXT:locationgallery/Resources/Private/Backend/Layouts/
}
}
如果我现在包含 'locationgallery' 的静态模板,它是通过 ExtensionManagementUtility::addStaticFile
添加的,那么在包含此模板的每个页面上一切正常。
我的问题是,我收到错误消息
Sorry, the requested view was not found.
The technical reason is: No template was found. ...
如果我 select 页面树中的页面不包含静态模板。
我现在的问题是我不想在根页面中包含静态模板,但是'locationgallery'的后端模块需要在所有页面上都可用。
我确实尝试使用 ExtensionManagementUtility::addPageTSConfig
包含配置的相应部分,用于将 TSConfig 添加到 $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig']
变量。但是在视图试图找到模板之前,这个 Typoscript 不会被解释。 (例如,据我所知,在这个 运行 期间它根本没有被解释,因为我发现只有 TemplateService::mergeConstantsFromPageTSconfig
和 TypoScriptFrontendController::getPagesTSconfig
指的是 $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig']
。)
我发现 powermail
使用 ext_typoscript_setup.typoscript, but this is deprecated according to https://forge.typo3.org/issues/52364 存档了我想要的内容。
此方法的另一个缺点是 'ext_typoscript_setup.typoscript' 的解释独立于后端和前端模式。
我想知道是否有任何未弃用的方法来为 Typo3 中的任何后端 运行 包含一些 TypoScript。
感谢您的任何建议。
您可以将您的 TS 设置拆分为多个文件以分隔包含内容。
在Configuration/TCA/Overrides/sys_template.php
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
'your_ext_key',
'Configuration/TypoScript/backend_or_however_you_call_it.typoscript',
'Your label'
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
'your_ext_key',
'Configuration/TypoScript/frontendend_or_however_you_call_it.typoscript',
'Your label'
);