简体   繁体   English

EXT的新闻小部件:新闻

[英]News Widget from EXT:news

Last week I started with TYPO3 and now I have to make an extension (widget) for a Dashboard plugin (where in the FE the User can select from a list of specific widgets and place them on this Dashboard). 上周,我开始使用TYPO3,现在我必须为Dashboard插件进行扩展(小部件)(用户可以在FE中从特定小部件列表中进行选择,并将其放置在此Dashboard上)。

The widget should be able to display the latest 5 of all news and (via dropdown) be able to show only the latest 5 news of a specific category. 该小部件应该能够显示所有最新消息中的5条消息,并且(通过下拉菜单)只能显示特定类别的最新5条消息。

For the News we're using EXT:news. 对于新闻,我们使用EXT:news。

And that's where I'm stuck now. 那就是我现在停留的地方。

In my custom extension, how can I access the deserved data (title, category and body) from the news-extension to pass it into my template? 在我的自定义扩展程序中,如何访问新闻扩展程序中应有的数据(标题,类别和正文)以将其传递到模板中?

This is pretty easy to do as you can completly reuse the NewsDemand object for filtering. 这很容易做到,因为您可以完全重用NewsDemand对象进行过滤。 An example looks like this: 一个示例如下所示:

$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);

Take a look at the NewsRepository which handles all the possibilities of the demand object. 看一下处理需求对象所有可能性的NewsRepository

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

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