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 {
$limit = ((int) $this->settings['limit']);
$limit = ($limit < 1 ? 1 : $limit);
$filterByCategories = FALSE;
$categoryUids = GeneralUtility::intExplode(',', $this->settings['categories']);
foreach ($categoryUids as $categoryUid) {
if ($categoryUid > 0) {
$filterByCategories = TRUE;
break;
}
$categoryUids = GeneralUtility::intExplode(',', $this->settings['categories'], TRUE);
if (!count($categoryUids) && (int) $GLOBALS['TSFE']->page['doktype'] === 117) {
$categoryUids = [$GLOBALS['TSFE']->id];
}
$latestNewsEntries = $this->newsRepository->findLastUpdatedOrHighlightedNewsByCategories(
$limit, FALSE, ($filterByCategories ? $categoryUids : NULL), 0, TRUE
$limit, FALSE, $categoryUids, 0, TRUE
);
$newsMetaData = [];
......@@ -73,7 +69,6 @@ class LatestController extends AbstractController {
foreach ($latestNewsEntries as $latestNewsEntry) {
/** @var News $latestNewsEntry */
/** @var Category $category */
$categoryUid = $latestNewsEntry->getPid();
$category = $categories[$categoryUid];
if (!$category) {
......@@ -90,5 +85,3 @@ class LatestController extends AbstractController {
$this->view->assign('newsMetaData', $newsMetaData);
}
}
?>
......@@ -99,7 +99,7 @@ class NewsRepository extends AbstractRepository {
) {
$query = $this->createQuery();
$constraints = NULL;
if ($categoryIds !== NULL && is_array($categoryIds)) {
if ($categoryIds !== NULL && count($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
to provide different rendering paths. Please look at the example below:
```
lib.pageTemplate.default >
lib.pageTemplate.default = FLUIDTEMPLATE
lib.pageTemplate.default {
file = EXT:project_theme/Resources/Private/Templates/Default.html
......@@ -19,6 +20,12 @@ lib.pageTemplate.default {
116 = TEXT
116.value =
117 = COA
117 {
10 < tt_content.list.20.sgnews_latest
20 < styles.content.col0
}
# just show the content
default < styles.content.col0
}
......@@ -31,7 +38,11 @@ lib.pageTemplate.default {
116 < tt_content.list.20.sgnews_singleview
# 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
default < styles.content.col1
......
......@@ -3,7 +3,15 @@
{namespace sg=SGalinski\SgNews\ViewHelpers}
<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">
<ul class="tx-sgnews-list row">
<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