Skip to content
Snippets Groups Projects
Commit 1c714616 authored by Tim Wagner's avatar Tim Wagner
Browse files

[TASK] Filter news overview by restricted tags/categories

parent 9987debb
No related branches found
No related tags found
1 merge request!28[FEATURE] News Overview Tag / Category Restrictions
......@@ -160,6 +160,19 @@ class OverviewController extends AbstractController {
return;
}
$categoryRestrictions = GeneralUtility::intExplode(',', $this->settings['categoryRestrictions'], TRUE);
if (count($categoryRestrictions) > 0) {
foreach ($categories as $key => $category) {
if (!in_array($category->getUid(), $categoryRestrictions, TRUE)) {
unset($categories[$key]);
}
}
}
if (count($categories) <= 0) {
return;
}
$startTime = (int) $this->settings['starttime'];
$endTime = (int) $this->settings['endtime'];
......@@ -331,6 +344,15 @@ class OverviewController extends AbstractController {
$tags = $this->tagRepository->findAll()->toArray();
}
$tagRestrictions = GeneralUtility::intExplode(',', $this->settings['tagRestrictions'], TRUE);
if (count($tagRestrictions) > 0) {
foreach ($tags as $key => $tag) {
if (!in_array($tag->getUid(), $tagRestrictions, TRUE)) {
unset($tags[$key]);
}
}
}
// Get news by tag id
$tagIds = [];
$tagsById = [];
......
......@@ -36,10 +36,10 @@
</TCEforms>
</settings.groupBy>
<settings.categories>
<settings.categoryRestrictions>
<TCEforms>
<label>LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:plugin.overview.flexForm.categories</label>
<description>LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:plugin.overview.flexForm.categories.description</description>
<label>LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:plugin.overview.flexForm.categoryRestrictions</label>
<description>LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:plugin.overview.flexForm.categoryRestrictions.description</description>
<displayCond>FIELD:settings.groupBy:=:1</displayCond>
<config>
<type>select</type>
......@@ -51,12 +51,12 @@
<foreign_table_where>AND pages.sys_language_uid IN (-1, 0) AND pages.doktype = 117 ORDER BY pages.title</foreign_table_where>
</config>
</TCEforms>
</settings.categories>
</settings.categoryRestrictions>
<settings.tags>
<settings.tagRestrictions>
<TCEforms>
<label>LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:plugin.flexForm.tags</label>
<description>LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:plugin.flexForm.tags.description</description>
<description>LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:plugin.overview.flexForm.tags.description</description>
<displayCond>FIELD:settings.groupBy:=:2</displayCond>
<config>
<type>select</type>
......@@ -75,7 +75,7 @@
</treeConfig>
</config>
</TCEforms>
</settings.tags>
</settings.tagRestrictions>
<settings.enableFilter>
<TCEforms>
......
......@@ -169,11 +169,11 @@
<source><![CDATA[only if endless scrolling is not enabled]]></source>
<target><![CDATA[nur wenn Endless Scrolling nicht aktiv ist]]></target>
</trans-unit>
<trans-unit id="plugin.overview.flexForm.categories" approved="yes">
<trans-unit id="plugin.overview.flexForm.categoryRestrictions" approved="yes">
<source><![CDATA[Category Selection]]></source>
<target><![CDATA[Kategorienauswahl]]></target>
</trans-unit>
<trans-unit id="plugin.overview.flexForm.categories.description" approved="yes">
<trans-unit id="plugin.overview.flexForm.categoryRestrictions.description" approved="yes">
<source><![CDATA[You can select specific categories to be shown in the tabs.
If none are selected, all categories will be available in the frontend.]]></source>
<target><![CDATA[Es werden nur ausgewählte Kategorien in den Tabs angezeigt.
......@@ -211,6 +211,12 @@ Wenn keine ausgewählt werden, sind alle Kategorien im Frontend verfügbar.]]></
<source><![CDATA[Include only news subpages of the page containing this overview]]></source>
<target><![CDATA[Beachte nur News-Unterseiten der Seite, die diese Übersicht beinhaltet]]></target>
</trans-unit>
<trans-unit id="plugin.overview.flexForm.tags.description" approved="yes">
<source><![CDATA[You can select specific tags to be shown in the tabs.
If none are selected, all tags will be available in the frontend.]]></source>
<target><![CDATA[Es werden nur ausgewählte Tags in den Tabs angezeigt.
Wenn keine ausgewählt werden, sind alle Tags im Frontend verfügbar.]]></target>
</trans-unit>
<trans-unit id="tx_sgnews_domain_model_author" approved="yes">
<source><![CDATA[Author]]></source>
<target><![CDATA[Autor]]></target>
......
......@@ -129,10 +129,10 @@
<trans-unit id="plugin.listByCategory.flexForm.newsLimitPerPage.description">
<source><![CDATA[only if endless scrolling is not enabled]]></source>
</trans-unit>
<trans-unit id="plugin.overview.flexForm.categories">
<trans-unit id="plugin.overview.flexForm.categoryRestrictions">
<source><![CDATA[Category Selection]]></source>
</trans-unit>
<trans-unit id="plugin.overview.flexForm.categories.description">
<trans-unit id="plugin.overview.flexForm.categoryRestrictions.description">
<source><![CDATA[You can select specific categories to be shown in the tabs.
If none are selected, all categories will be available in the frontend.]]></source>
</trans-unit>
......@@ -160,6 +160,10 @@ If none are selected, all categories will be available in the frontend.]]></sour
<trans-unit id="plugin.overview.flexForm.onlyNewsWithinThisPageSection">
<source><![CDATA[Include only news subpages of the page containing this overview]]></source>
</trans-unit>
<trans-unit id="plugin.overview.flexForm.tags.description">
<source><![CDATA[You can select specific tags to be shown in the tabs.
If none are selected, all tags will be available in the frontend.]]></source>
</trans-unit>
<trans-unit id="tx_sgnews_domain_model_author">
<source><![CDATA[Author]]></source>
</trans-unit>
......
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