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