首页 > 解决方案 > 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 吗?

标签: phptypo3typo3-8.xtypo3-extensions

解决方案


在 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;

推荐阅读