来自 EXT:news 的新闻小部件

News Widget from EXT:news

上周我开始使用 TYPO3,现在我必须为仪表板插件做一个扩展(小部件)(在 FE 中,用户可以 select 从特定小部件列表中将它们放在这个仪表板)。

小部件应该能够显示所有新闻中的最新 5 条,并且(通过下拉菜单)能够仅显示特定类别的最新 5 条新闻。

对于新闻,我们使用 EXT:news。

这就是我现在遇到的问题。

在我的自定义扩展中,如何从 news-extension 访问应有的数据(标题、类别和 body)以将其传递到我的模板中?

这很容易做到,因为您可以完全重复使用 NewsDemand 对象进行过滤。示例如下所示:

$newsRepository = $this->objectManager->get(NewsRepository::class);
$demand = $this->objectManager->get(NewsDemand::class);
$demand->setStoragePage('123');
$demand->setLimit(3);
$demand->setCategories(['12', '34']);
$demand->setCategoryConjunction('or');
$items = $newsRepository->findDemanded($demand);
$this->view->assign('items', $items);

看看NewsRepository处理需求对象的所有可能性