php - TYPO3 8.7 扩展 - 缺少存储页面 ID
问题描述
我有一个带有插件的扩展。我希望扩展的默认 storagePid 是在“数据集集合”字段中设置的任何内容 - 据我所知,这无论如何都是标准设置。
我的 setup.ts 和 constants.ts 没有在任何地方提到 storagePid(我读到如果它放在 setup.ts 文件中,它会覆盖默认的 storagePid 编号)
当我运行插件时,控制器会调用一个存储库。存储库进行查询,我告诉它尊重 PID 存储:
$query = $this->createQuery();
$query->getQuerySettings()->setRespectStoragePage(TRUE);
....
但是当我运行它时,我收到以下错误。
Oops, an error occurred!
Missing storage page ids.
作为测试,我打印出控制器认为 storagePid 应该是什么:
$configuration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
print( "pluginpid = ".$configuration['persistence']['storagePid']);
...打印出正确的数字。所以控制器知道 storagePid 号是多少,但存储库不知道。(并且上面的打印输出仅适用于控制器,不适用于 repo)
有人知道为什么我的存储库不知道/使用我设置的 storagePid 吗?
解决方案
在 constants.ts 添加persistence
部分,因此可以通过模板模块的常量编辑器使用。IE:
plugin.tx_yourextension_yourplugin {
view {
# cat=plugin.tx_yourextension_yourplugin/file; type=string; label=Path to template root (FE)
templateRootPath = EXT:yourextension/Resources/Private/Templates/
# cat=plugin.tx_yourextension_yourplugin/file; type=string; label=Path to template partials (FE)
partialRootPath = EXT:yourextension/Resources/Private/Partials/
# cat=plugin.tx_yourextension_yourplugin/file; type=string; label=Path to template layouts (FE)
layoutRootPath = EXT:yourextension/Resources/Private/Layouts/
}
persistence {
# cat=plugin.tx_yourextension_yourplugin//a; type=string; label=Default storage PID
storagePid =
}
}
稍后在您的 setup.ts 中通过以下方式重写它:
plugin.tx_yourextension_yourplugin {
view {
templateRootPaths.0 = EXT:{extension.shortExtensionKey}/Resources/Private/Templates/
templateRootPaths.1 = {$plugin.tx_yourextension_yourplugin.view.templateRootPath}
partialRootPaths.0 = EXT:yourextension/Resources/Private/Partials/
partialRootPaths.1 = {$plugin.tx_yourextension_yourplugin.view.partialRootPath}
layoutRootPaths.0 = EXT:tx_yourextension/Resources/Private/Layouts/
layoutRootPaths.1 = {$plugin.tx_yourextension_yourplugin.view.layoutRootPath}
}
persistence {
storagePid = {$plugin.tx_yourextension_yourplugin.persistence.storagePid}
#recursive = 1
}
}
提示零:总是多次清除缓存;)
提示 1:当使用 Extension Builder 引导您的新 ext 时,如果您在其中添加了 FE 插件,它应该添加适当的常量和设置文件。
提示2:而不是print()
更好地使用
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($debuggedData, 'Title');
当然,你可以在你的控制器中导入它
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
推荐阅读
- mediapipe - 是项目 https://github.com/google/mediapipe opensourse
- java - 用于实现不断变化的组件的更好的设计模式
- mongodb - 使用 mongodb 作为数据库的微服务部署的主节点和工作节点需要多少 CPU 和 RAM?
- oracle - 如何在 edb 中使用相同的 REGEXP_REPLACE(Oracle sql)
- python - 在 google colabs python 中替换 2.5.0 版 tensorflows 占位符的最佳方法是什么?
- reactjs - 过滤列表时如何保留选中的值
- javascript - 如何在币安 api 中设置买单
- excel - 如何使用 Randomize 使我的 UDF 成为非易失性?
- react-native - 使用 React Navigation 测试 React Native 的问题
- tkinter - Tkinter 避免/禁用窗口移动(或其拖动)