TYPO3 Extbase: Set storagepid for Backend Module

时光总嘲笑我的痴心妄想 提交于 2019-12-12 01:42:53

问题


I have written a small extension that provide news for Backend User. Ist is just 2 Parts. One part showing the news for all BE User as a own Module, and the other part are create and edit functions provided by the TCA.

To work with the TCA forms and the default extbase getter, i need the correct storagePid. I can't set them via TypoScript, because I'm never in a page context.

My Idea was to use the Plugin settings with the file ext_conf_template.txt

# cat=persistence/enable; type=int; label=Storage pid
storagePid = 4457

But how can I tell TYPO3 to look at this Settings?

At least Repository->findAll() must respect it


回答1:


Normally you would define this using TypoScript:

module.tx_yourextensionkey.persistence.storagePid = 123

Not being in a page context is not a blocker as long as you place the configuration on the first root TypoScript template (or include the TypoScript via other means which cause global inclusion not specific to any sys_template record or page tree location).




回答2:


Maybe not the best solution, but it works.

I have written my own function in the repository with the pid as parameter. I'm using the TYPO3 Query builder.
With $query->equals('pid', $pid); I get entries with my pid.
And with $query->getQuerySettings()->setRespectStoragePage(false); the default pid will be ignored.

And as the last step. My Controller gets the pid from the Settings, unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['my_extension']['storagePid']); an gives it to the function.



来源:https://stackoverflow.com/questions/39473246/typo3-extbase-set-storagepid-for-backend-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!