简体   繁体   中英

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).

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.

For the News we're using 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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