[英]TYPO3 Extbase: Set storagepid for Backend Module
I have written a small extension that provide news for Backend User. 我写了一个小扩展程序,为后端用户提供新闻。 Ist is just 2 Parts. Ist只是2个部分。 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. 一部分将所有BE用户的新闻显示为一个单独的模块,另一部分是TCA提供的创建和编辑功能。
To work with the TCA forms and the default extbase getter, i need the correct storagePid. 要使用TCA表单和默认的extbase getter,我需要正确的storagePid。 I can't set them via TypoScript, because I'm never in a page context . 我无法通过TypoScript设置它们,因为我从来不在页面上下文中 。
My Idea was to use the Plugin settings with the file ext_conf_template.txt
我的想法是将插件设置与文件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? 但是如何告诉TYPO3查看此设置?
At least Repository->findAll()
must respect it 至少Repository->findAll()
必须尊重它
Normally you would define this using TypoScript: 通常,您可以使用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). 只要您将配置放在第一个根TypoScript模板上(或通过其他方式包含TypoScript,这会导致不专门针对任何sys_template
记录或页面树的位置进行全局包含),不在页面上下文中就不会成为sys_template
。
Maybe not the best solution, but it works. 也许不是最好的解决方案,但它可以工作。
I have written my own function in the repository with the pid as parameter. 我已经使用pid作为参数在存储库中编写了自己的函数。 I'm using the TYPO3 Query builder. 我正在使用TYPO3查询构建器。
With $query->equals('pid', $pid);
使用$query->equals('pid', $pid);
I get entries with my pid. 我收到我的PID条目。
And with $query->getQuerySettings()->setRespectStoragePage(false);
并使用$query->getQuerySettings()->setRespectStoragePage(false);
the default pid will be ignored. 默认的pid将被忽略。
And as the last step. 并作为最后一步。 My Controller gets the pid from the Settings, unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['my_extension']['storagePid']);
我的控制器从设置中获取pid,反unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['my_extension']['storagePid']);
an gives it to the function. 一个给它的功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.