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

[FEATURE] Allow the rendering of the latest view via typoscript on category pages

parent 77e580bf
No related branches found
No related tags found
No related merge requests found
...@@ -55,17 +55,13 @@ class LatestController extends AbstractController { ...@@ -55,17 +55,13 @@ class LatestController extends AbstractController {
$limit = ((int) $this->settings['limit']); $limit = ((int) $this->settings['limit']);
$limit = ($limit < 1 ? 1 : $limit); $limit = ($limit < 1 ? 1 : $limit);
$filterByCategories = FALSE; $categoryUids = GeneralUtility::intExplode(',', $this->settings['categories'], TRUE);
$categoryUids = GeneralUtility::intExplode(',', $this->settings['categories']); if (!count($categoryUids) && (int) $GLOBALS['TSFE']->page['doktype'] === 117) {
foreach ($categoryUids as $categoryUid) { $categoryUids = [$GLOBALS['TSFE']->id];
if ($categoryUid > 0) {
$filterByCategories = TRUE;
break;
}
} }
$latestNewsEntries = $this->newsRepository->findLastUpdatedOrHighlightedNewsByCategories( $latestNewsEntries = $this->newsRepository->findLastUpdatedOrHighlightedNewsByCategories(
$limit, FALSE, ($filterByCategories ? $categoryUids : NULL), 0, TRUE $limit, FALSE, $categoryUids, 0, TRUE
); );
$newsMetaData = []; $newsMetaData = [];
...@@ -73,7 +69,6 @@ class LatestController extends AbstractController { ...@@ -73,7 +69,6 @@ class LatestController extends AbstractController {
foreach ($latestNewsEntries as $latestNewsEntry) { foreach ($latestNewsEntries as $latestNewsEntry) {
/** @var News $latestNewsEntry */ /** @var News $latestNewsEntry */
/** @var Category $category */ /** @var Category $category */
$categoryUid = $latestNewsEntry->getPid(); $categoryUid = $latestNewsEntry->getPid();
$category = $categories[$categoryUid]; $category = $categories[$categoryUid];
if (!$category) { if (!$category) {
...@@ -90,5 +85,3 @@ class LatestController extends AbstractController { ...@@ -90,5 +85,3 @@ class LatestController extends AbstractController {
$this->view->assign('newsMetaData', $newsMetaData); $this->view->assign('newsMetaData', $newsMetaData);
} }
} }
?>
...@@ -99,7 +99,7 @@ class NewsRepository extends AbstractRepository { ...@@ -99,7 +99,7 @@ class NewsRepository extends AbstractRepository {
) { ) {
$query = $this->createQuery(); $query = $this->createQuery();
$constraints = NULL; $constraints = NULL;
if ($categoryIds !== NULL && is_array($categoryIds)) { if ($categoryIds !== NULL && count($categoryIds)) {
$constraints[] = $query->in('pid', $categoryIds); $constraints[] = $query->in('pid', $categoryIds);
} }
......
...@@ -6,6 +6,7 @@ extension itself provides two new doktypes, we can simply add a switch case to o ...@@ -6,6 +6,7 @@ extension itself provides two new doktypes, we can simply add a switch case to o
to provide different rendering paths. Please look at the example below: to provide different rendering paths. Please look at the example below:
``` ```
lib.pageTemplate.default >
lib.pageTemplate.default = FLUIDTEMPLATE lib.pageTemplate.default = FLUIDTEMPLATE
lib.pageTemplate.default { lib.pageTemplate.default {
file = EXT:project_theme/Resources/Private/Templates/Default.html file = EXT:project_theme/Resources/Private/Templates/Default.html
...@@ -19,6 +20,12 @@ lib.pageTemplate.default { ...@@ -19,6 +20,12 @@ lib.pageTemplate.default {
116 = TEXT 116 = TEXT
116.value = 116.value =
117 = COA
117 {
10 < tt_content.list.20.sgnews_latest
20 < styles.content.col0
}
# just show the content # just show the content
default < styles.content.col0 default < styles.content.col0
} }
...@@ -31,7 +38,11 @@ lib.pageTemplate.default { ...@@ -31,7 +38,11 @@ lib.pageTemplate.default {
116 < tt_content.list.20.sgnews_singleview 116 < tt_content.list.20.sgnews_singleview
# show the category view of the news if the page type matches # show the category view of the news if the page type matches
117 < tt_content.list.20.sgnews_listbycategory 117 = COA
117 {
10 < tt_content.list.20.sgnews_listbycategory
20 < styles.content.col1
}
# just show the content # just show the content
default < styles.content.col1 default < styles.content.col1
......
...@@ -3,7 +3,15 @@ ...@@ -3,7 +3,15 @@
{namespace sg=SGalinski\SgNews\ViewHelpers} {namespace sg=SGalinski\SgNews\ViewHelpers}
<f:section name="main"> <f:section name="main">
<section class="content light-bg "> <section class="content light-bg">
<div class="container">
<f:for each="{categories}" as="category">
<h2 class="tx-sgnews-category-title">{category.subtitleWithFallbackToTitle}</h2>
</f:for>
</div>
</section>
<section class="content light-bg">
<div class="container tx-sgnews-categories"> <div class="container tx-sgnews-categories">
<ul class="tx-sgnews-list row"> <ul class="tx-sgnews-list row">
<f:for each="{newsMetaData}" as="newsMetaDataEntry"> <f:for each="{newsMetaData}" as="newsMetaDataEntry">
......
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