简体   繁体   中英

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.

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)

When I run the plugin, the controller calls a repository. The repository makes a query, and I have told it to respect the PID storage:

$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:

$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. (and the printout above only works in a controller, doesn't work in a repo)

Does anybody know why my repository doesn't know/use the storagePid that I've set?

In constants.ts add persistence section, so it will be available trough constants editor of Template module. 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:

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.

Tip 2: instead of print() it's better to use

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

of course, you can import it in your controller

use TYPO3\CMS\Extbase\Utility\DebuggerUtility;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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