简体   繁体   English

TYPO3 8.7 扩展 - 缺少存储页面 ID

[英]TYPO3 8.7 Extension - Missing storage page ids

I have an extension with a plugin.我有一个带有插件的扩展。 I want the default storagePid for the extension to be whatever it is set as in the "Data set collection" field - to my knowledge this is the standard setup anyway.我希望扩展的默认 storagePid 是在“数据集集合”字段中设置的任何内容 - 据我所知,这无论如何都是标准设置。

My setup.ts and constants.ts do not mention the storagePid anywhere (I read that if it is placed in the setup.ts file it overrides the default storagePid number)我的 setup.ts 和 constants.ts 没有在任何地方提到 storagePid(我读到如果它放在 setup.ts 文件中,它会覆盖默认的 storagePid 编号)

When I run the plugin, the controller calls a repository.当我运行插件时,controller 调用一个存储库。 The repository makes a query, and I have told it to respect the PID storage:存储库进行查询,我告诉它尊重 PID 存储:

$query = $this->createQuery();
$query->getQuerySettings()->setRespectStoragePage(TRUE);
....

But when I run it I get the following error.但是当我运行它时,我收到以下错误。

Oops, an error occurred!
Missing storage page ids.

As a test, I printed out what the Controller thought the storagePid should be:作为测试,我打印出 Controller 认为 storagePid 应该是什么:

$configuration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
print( "pluginpid = ".$configuration['persistence']['storagePid']);

...which printed out the correct number. ...打印出正确的数字。 So the controller knows what the storagePid number is, but the repository does not.所以 controller 知道 storagePid 号是多少,但存储库不知道。 (and the printout above only works in a controller, doesn't work in a repo) (并且上面的打印输出仅适用于 controller,不适用于 repo)

Does anybody know why my repository doesn't know/use the storagePid that I've set?有人知道为什么我的存储库不知道/使用我设置的 storagePid 吗?

In constants.ts add persistence section, so it will be available trough constants editor of Template module.在 constants.ts 添加persistence部分,因此可以通过模板模块的常量编辑器使用它。 ie: 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 =
    }
}

later in your setup.ts rewrite it by:稍后在您的 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
    }
   
} 

Tip ZERO: Always clear cache several times;)提示零:总是多次清除缓存;)

Tip 1: When using Extension Builder for bootstraping your new ext it should add proper constants and setup files if you added a FE plugin in it.提示 1:当使用 Extension Builder 引导您的新 ext 时,如果您在其中添加了 FE 插件,它应该添加适当的常量设置文件。

Tip 2: instead of print() it's better to use提示 2:而不是print()最好使用

\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($debuggedData, 'Title');

of course, you can import it in your controller当然,您可以将其导入 controller

use TYPO3\CMS\Extbase\Utility\DebuggerUtility;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM