Skip to content
Snippets Groups Projects
Commit fc9fcf9b authored by Stefan Galinski's avatar Stefan Galinski :video_game:
Browse files

[FEATURE] Add all tab to the overview category list

parent 922659cf
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,11 @@ abstract class AbstractController extends ActionController {
*/
protected $extensionConfiguration = [];
/**
* @var array
*/
protected $cachedSingleNews = [];
/**
* Initializes any action
*
......@@ -78,6 +83,11 @@ abstract class AbstractController extends ActionController {
* @return array
*/
protected function getMetaDataForNews(News $news, Category $category) {
$newsId = $news->getUid();
if (isset($this->cachedSingleNews[$newsId])) {
return $this->cachedSingleNews[$newsId];
}
$singleNewsImageData = $this->getDataForSingleViewImage($news, $category);
$teaserImageData = $this->getDataForTeaserImage($news, $category);
......@@ -91,7 +101,7 @@ abstract class AbstractController extends ActionController {
];
}
return array_merge(
$newsRecord = array_merge(
[
'category' => $category,
'news' => $news,
......@@ -99,6 +109,10 @@ abstract class AbstractController extends ActionController {
$singleNewsImageData,
$teaserImageData
);
$this->cachedSingleNews[$newsId] = $newsRecord;
return $newsRecord;
}
/**
......
......@@ -90,7 +90,6 @@ class OverviewController extends AbstractController {
* @return void
*/
protected function overviewWithCategories() {
$newsByCategory = [];
$newsLimitPerCategory = (int) $this->settings['newsLimit'];
$this->categoryRepository->setDefaultOrderings(['sorting' => Query::ORDER_ASCENDING]);
......@@ -108,34 +107,53 @@ class OverviewController extends AbstractController {
}
$categoryIds = [];
$categoriesById = [];
$newsMetaData = [];
foreach ($categories as $category) {
/** @var Category $category */
/** @var $category Category */
$categoryId = $category->getUid();
$categoryIds[] = $categoryId;
$categoryIds[] = $category->getUid();
$categoriesById[$categoryId] = $category;
$newsMetaData = [];
$news = $this->newsRepository->findAllSortedNewsByCategories([$categoryId], $newsLimitPerCategory, $offset);
foreach ($news as $newsEntry) {
/** @var News $newsEntry */
$categoryId = $newsEntry->getPid();
$category = $categoriesById[$categoryId];
$data = $this->getMetaDataForNews($newsEntry, $category);
$newsMetaData[] = $data;
$newsMetaData[$categoryId][] = $data;
}
}
/** @noinspection PhpUndefinedMethodInspection */
$newsByCategory = [];
foreach ($categoriesById as $categoryId => $category) {
/** @var $category Category */
$newsByCategory[$categoryId] = [
'category' => $category,
'categoryId' => $categoryId,
'newsCount' => $this->newsRepository->countByPid($categoryId),
'newsMetaData' => $newsMetaData
'newsMetaData' => $newsMetaData[$categoryId]
];
}
$allNews = [];
$news = $this->newsRepository->findAllSortedNewsByCategories($categoryIds, $newsLimitPerCategory, $offset);
foreach ($news as $newsEntry) {
/** @var News $newsEntry */
$categoryId = $newsEntry->getPid();
$category = $categoriesById[$categoryId];
$data = $this->getMetaDataForNews($newsEntry, $category);
$allNews[] = $data;
}
$this->highlightBestFitNews($categoryIds);
$newsCount = $this->newsRepository->newsCountByCategories($categoryIds);
$numberOfPages = ($newsLimitPerCategory <= 0 ? 0 : ceil($newsCount / $newsLimitPerCategory));
$this->view->assign('numberOfPages', $numberOfPages);
$this->view->assign('newsByCategory', $newsByCategory);
$this->view->assign('allNews', $allNews);
}
/**
......
......@@ -9,42 +9,46 @@
<authorEmail>stefan@sgalinski.de</authorEmail>
</header>
<body>
<trans-unit id="frontend.overview.category.allArticles" approved="yes">
<source>All Articles</source>
<target>Alle Artikel</target>
</trans-unit>
<trans-unit id="frontend.overview.showAllEntries" approved="yes">
<source>All News</source>
<target>Alle Beiträge</target>
</trans-unit>
<trans-unit id="frontend.singleview.author" approved="yes">
<source>The author:</source>
<target>Der Autor:</target>
</trans-unit>
<trans-unit id="frontend.singleview.nextArticle" approved="yes">
<source>Next Article</source>
<target>Nächster Artikel</target>
</trans-unit>
<trans-unit id="frontend.singleview.previousArticle" approved="yes">
<source>Previous Article</source>
<target>Vorheriger Artikel</target>
</trans-unit>
<trans-unit id="frontend.singleview.readingTime" approved="yes">
<source>Reading Time:</source>
<target>Lesezeit:</target>
</trans-unit>
<trans-unit id="frontend.singleview.relatedArticles" approved="yes">
<source>Related Articles</source>
<target>Verwandte Artikel</target>
</trans-unit>
<trans-unit id="frontend.singleview.similarArticle" approved="yes">
<source>These articles could interest you too:</source>
<target>Diese Artikel könnten Dich auch interessieren:</target>
</trans-unit>
<trans-unit id="frontend.teaser.readMore" approved="yes">
<source>read more</source>
<target>weiterlesen</target>
</trans-unit>
<trans-unit id="frontend.overview.allTabLabel" approved="yes">
<source>All</source>
<target>Alle</target>
</trans-unit>
<trans-unit id="frontend.overview.category.allArticles" approved="yes">
<source>All Articles</source>
<target>Alle Artikel</target>
</trans-unit>
<trans-unit id="frontend.overview.showAllEntries" approved="yes">
<source>All News</source>
<target>Alle Beiträge</target>
</trans-unit>
<trans-unit id="frontend.singleview.author" approved="yes">
<source>The author:</source>
<target>Der Autor:</target>
</trans-unit>
<trans-unit id="frontend.singleview.nextArticle" approved="yes">
<source>Next Article</source>
<target>Nächster Artikel</target>
</trans-unit>
<trans-unit id="frontend.singleview.previousArticle" approved="yes">
<source>Previous Article</source>
<target>Vorheriger Artikel</target>
</trans-unit>
<trans-unit id="frontend.singleview.readingTime" approved="yes">
<source>Reading Time:</source>
<target>Lesezeit:</target>
</trans-unit>
<trans-unit id="frontend.singleview.relatedArticles" approved="yes">
<source>Related Articles</source>
<target>Verwandte Artikel</target>
</trans-unit>
<trans-unit id="frontend.singleview.similarArticle" approved="yes">
<source>These articles could interest you too:</source>
<target>Diese Artikel könnten Dich auch interessieren:</target>
</trans-unit>
<trans-unit id="frontend.teaser.readMore" approved="yes">
<source>read more</source>
<target>weiterlesen</target>
</trans-unit>
</body>
</file>
</xliff>
</xliff>
\ No newline at end of file
......@@ -9,33 +9,36 @@
<authorEmail>stefan@sgalinski.de</authorEmail>
</header>
<body>
<trans-unit id="frontend.overview.category.allArticles">
<source>All Articles</source>
</trans-unit>
<trans-unit id="frontend.overview.showAllEntries">
<source>All News</source>
</trans-unit>
<trans-unit id="frontend.singleview.author">
<source>The author:</source>
</trans-unit>
<trans-unit id="frontend.singleview.nextArticle">
<source>Next Article</source>
</trans-unit>
<trans-unit id="frontend.singleview.previousArticle">
<source>Previous Article</source>
</trans-unit>
<trans-unit id="frontend.singleview.readingTime">
<source>Reading Time:</source>
</trans-unit>
<trans-unit id="frontend.singleview.relatedArticles">
<source>Related Articles</source>
</trans-unit>
<trans-unit id="frontend.singleview.similarArticle">
<source>These articles could interest you too:</source>
</trans-unit>
<trans-unit id="frontend.teaser.readMore">
<source>read more</source>
</trans-unit>
<trans-unit id="frontend.overview.allTabLabel">
<source>All</source>
</trans-unit>
<trans-unit id="frontend.overview.category.allArticles">
<source>All Articles</source>
</trans-unit>
<trans-unit id="frontend.overview.showAllEntries">
<source>All News</source>
</trans-unit>
<trans-unit id="frontend.singleview.author">
<source>The author:</source>
</trans-unit>
<trans-unit id="frontend.singleview.nextArticle">
<source>Next Article</source>
</trans-unit>
<trans-unit id="frontend.singleview.previousArticle">
<source>Previous Article</source>
</trans-unit>
<trans-unit id="frontend.singleview.readingTime">
<source>Reading Time:</source>
</trans-unit>
<trans-unit id="frontend.singleview.relatedArticles">
<source>Related Articles</source>
</trans-unit>
<trans-unit id="frontend.singleview.similarArticle">
<source>These articles could interest you too:</source>
</trans-unit>
<trans-unit id="frontend.teaser.readMore">
<source>read more</source>
</trans-unit>
</body>
</file>
</xliff>
</xliff>
\ No newline at end of file
......@@ -9,6 +9,11 @@
<a class="tabs-menu-button" href="#">Kategorie <span></span></a>
<ul class="tx-sgnews-categories-tabmenu tabs-menu-list nav nav-tabs">
<li class="tx-sgnews-category">
<a class="category-0" data-tab="tx-sgnews-categories-tabcontent0" href="#tx-sgnews-categories-tabcontent0">
<f:translate key="frontend.overview.allTabLabel" />
</a>
</li>
<f:for each="{newsByCategory}" as="dataByCategory">
<li class="tx-sgnews-category">
<a class="category-{dataByCategory.category.uid}" data-tab="tx-sgnews-categories-tabcontent{dataByCategory.category.uid}" href="#tx-sgnews-categories-tabcontent{dataByCategory.category.uid}">
......@@ -20,6 +25,21 @@
</div>
<div class="tx-sgnews-categories-tabcontents tabs-contents">
<div class="tx-sgnews-categories-tabcontent" id="tx-sgnews-categories-tabcontent0">
<h4 class="tx-sgnews-tab-title">{dataByCategory.category.title}</h4>
<ul class="tx-sgnews-list tx-sgnews-list-0 row" data-category="0">
<f:for each="{allNews}" as="newsMetaDataEntry">
<li class="col-md-4 col-sm-6 col-xs-12">
<f:render partial="Teaser" arguments="{
newsMetaData: newsMetaDataEntry,
headerTag: '<h2>',
closingHeaderTag: '</h2>',
showCategory: 0
}" />
</li>
</f:for>
</ul>
</div>
<f:for each="{newsByCategory}" as="dataByCategory">
<div class="tx-sgnews-categories-tabcontent" id="tx-sgnews-categories-tabcontent{dataByCategory.category.uid}">
<h4 class="tx-sgnews-tab-title">{dataByCategory.category.title}</h4>
......
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