Skip to content
Snippets Groups Projects
Commit 45f8d603 authored by Fabian Galinski's avatar Fabian Galinski :pouting_cat:
Browse files

[FEATURE] Adds the categories to the feed template

parent 899f8a7d
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,8 @@ namespace SGalinski\SgNews\Controller;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use SGalinski\SgNews\Domain\Model\News;
use SGalinski\SgNews\Domain\Repository\CategoryRepository;
use SGalinski\SgNews\Domain\Repository\NewsRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -52,7 +54,26 @@ class NewsFeedController extends AbstractController {
$news = $this->newsRepository->findLastUpdatedOrHighlightedNewsByCategories(
10, FALSE, $categories, 0, FALSE, 'date', $tags, $startTime, $endTime
);
$newsCategories = [];
$categoryRepository = $this->objectManager->get(CategoryRepository::class);
foreach ($news as $newsEntry) {
/** @var News $newsEntry */
$categoryId = $newsEntry->getPid();
if (isset($newsCategories[$categoryId])) {
continue;
}
$newsCategory = $categoryRepository->findByUid($categoryId);
if (!$newsCategory) {
continue;
}
$newsCategories[$categoryId] = $newsCategory;
}
$this->view->assign('news', $news);
$this->view->assign('newsCategories', $newsCategories);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment