简体   繁体   English

从tt_news导入,并在tt_news和新闻中添加其他字段(TYPO3 8 LTS)

[英]Import from tt_news with additional fields in tt_news and news (TYPO3 8 LTS)

import from tt_news in TYPO3 8 LTS with actual news and news_ttnewsimport is working fine. 从TYPO3 8 LTS中的tt_news导入实际新闻和news_ttnewsimport可以正常工作。 But we had some individual fields in tt_news and i want to import theese fields too in individuel fields in news. 但是我们在tt_news中有一些单独的字段,我也想在新闻的个人字段中导入这些主题。

So i made a new extension which extends news with individual fields. 因此,我做了一个新扩展,将新闻扩展到各个领域。 It is working fine: i can edit them in the backend and print content in the frontend. 运行正常:我可以在后端编辑它们,并在前端打印内容。

Then i modified getImportData() in TTNewsNewsDataProviderService of news_ttnewsimport and added my new fields. 然后,我在news_ttnewsimport的TTNewsNewsDataProviderService中修改了getImportData()并添加了新字段。 The content of the individual fields of tt_news is fetched, i controlled it with a log-file. 已获取tt_news各个字段的内容,我用一个日志文件对其进行了控制。 But the content was not written in the database ... I controlled the getter and setter in my configuration of news but all seems correct. 但是内容没有写在数据库中……我在新闻配置中控制了getter和setter,但一切似乎都是正确的。

After some debugging i found that all commands which write the content in news are hardcoded in news/Classes/Domain/Service/NewsImportService.php: 经过一些调试后,我发现所有在新闻中写入内容的命令都被硬编码在news / Classes / Domain / Service / NewsImportService.php中:

$news->setAuthor($importItem['author']);

After adding my fields all works: 在添加我的字段后,所有的作品:

$news->setMyNewField($importItem['my_new_field']);

So my problem is fixed ... well some how: it seems dirty to change a class of an extension in order to handle individual fields. 所以我的问题已经解决了……还有一些方法:更改扩展类以处理各个字段似乎很脏。

Is there a correct possibility to make the import work with individual fields, without patching news? 是否有可能使导入与单个字段一起工作而不修补新闻?

Thanks! 谢谢!

In version 7 of tx_news i found the answer of my question ... i don't know wether it exists in older versions but in 7.1 it is possible to use a signal slot for this task: 在tx_news的版本7中,我找到了问题的答案...我不知道它是否存在于较旧的版本中,但在7.1中,可以使用信号插槽来完成此任务:

link to the manual: Prehydrate slot 链接到手册:预水槽

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

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