diff --git a/Classes/Domain/Model/News.php b/Classes/Domain/Model/News.php index f6e06c12d0c02c5a76e2658b1778f2fedc2b8c35..bb9b2df7b38e8e27d713819b17714712fa5f92b1 100644 --- a/Classes/Domain/Model/News.php +++ b/Classes/Domain/Model/News.php @@ -97,6 +97,11 @@ class News extends CategoryAndNews { */ protected $contentFromAnotherPage = 0; + /** + * @var bool + */ + protected $enableComments = TRUE; + /** * Constructor */ @@ -383,4 +388,18 @@ class News extends CategoryAndNews { public function setContentFromAnotherPage(int $contentFromAnotherPage): void { $this->contentFromAnotherPage = $contentFromAnotherPage; } + + /** + * @return bool + */ + public function getEnableComments(): bool { + return $this->enableComments; + } + + /** + * @param bool $enableComments + */ + public function setEnableComments(bool $enableComments): void { + $this->enableComments = $enableComments; + } } diff --git a/Configuration/Extbase/Persistence/Classes.php b/Configuration/Extbase/Persistence/Classes.php index 1630518858a63d3e3784138bd2f1f0597cba9fe9..bd14047d646e2916741aab1b5792740200bbc634 100644 --- a/Configuration/Extbase/Persistence/Classes.php +++ b/Configuration/Extbase/Persistence/Classes.php @@ -46,6 +46,9 @@ return [ ], 'dateEnd' => [ 'fieldName' => 'tx_sgnews_date_end' + ], + 'enableComments' => [ + 'fieldName' => 'tx_sgnews_comments_enable' ] ] ], diff --git a/Configuration/TCA/Overrides/pages.php b/Configuration/TCA/Overrides/pages.php index 4e66b8171a91d41bbffe6f1cf1cd40e876ba2aa2..89fe28395137c140dcd5645668a8ae94ba8d72f2 100644 --- a/Configuration/TCA/Overrides/pages.php +++ b/Configuration/TCA/Overrides/pages.php @@ -445,6 +445,14 @@ if (version_compare(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getExten 'allowLanguageSynchronization' => TRUE ] ] + ], + 'tx_sgnews_comments_enable' => [ + 'exclude' => TRUE, + 'label' => $localLangDbPath . 'pages.tx_sgnews_comments_enable', + 'config' => [ + 'type' => 'check', + 'default' => 1 + ] ] ] ); @@ -456,7 +464,8 @@ $GLOBALS['TCA']['pages']['palettes']['titleDescriptionAndHighlightFlag'] = [ --linebreak--, slug, --linebreak--, tx_projectbase_path_segment, tx_projectbase_excludefromsluggeneration, --linebreak--, tx_realurl_pathsegment, tx_realurl_exclude, - --linebreak--, tx_sgnews_highlighted, tx_sgnews_never_highlighted', + --linebreak--, tx_sgnews_highlighted, tx_sgnews_never_highlighted, + --linebreak--, tx_sgnews_comments_enable', 'canNotCollapse' => 1, ]; @@ -492,6 +501,7 @@ foreach ($GLOBALS['TCA']['pages']['columns'] as $languageExcludeField => $_) { 'tx_sgnews_date_end', 'tx_sgnews_highlighted', 'tx_sgnews_never_highlighted', + 'tx_sgnews_comments_enable', 'og_title', 'og_description', 'og_image', @@ -523,6 +533,7 @@ foreach ($GLOBALS['TCA']['pages']['columns'] as $languageExcludeField => $_) { 'tx_sgnews_date_end', 'tx_sgnews_highlighted', 'tx_sgnews_never_highlighted', + 'tx_sgnews_comments_enable' ]; } if (!in_array($languageExcludeField, $fieldNames)) { diff --git a/Resources/Private/Language/de.locallang_db.xlf b/Resources/Private/Language/de.locallang_db.xlf index 86abb8f74abddafa518c6a7cee73edb3b465ce6c..22069fcaa5e58020b26571c5b28a768defbbb1e2 100644 --- a/Resources/Private/Language/de.locallang_db.xlf +++ b/Resources/Private/Language/de.locallang_db.xlf @@ -81,6 +81,10 @@ <source><![CDATA[Use Image Cropping]]></source> <target><![CDATA[Bild-Cropping aktivieren]]></target> </trans-unit> + <trans-unit id="pages.tx_sgnews_comments_enable" approved="yes"> + <source><![CDATA[Enable comments on this page]]></source> + <target><![CDATA[Kommentare auf dieser Seite aktivieren]]></target> + </trans-unit> <trans-unit id="plugin.flexForm" approved="yes"> <source><![CDATA[Settings]]></source> <target><![CDATA[Einstellungen]]></target> diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index 4b662ac7e4d78df18ad3830e3244c7abfe36f119..a24ed7c27096f50f44c0e42f5be02a6a69ad3954 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -63,6 +63,9 @@ <trans-unit id="pages.tx_sgnews_use_image_crop"> <source><![CDATA[Use Image Cropping]]></source> </trans-unit> + <trans-unit id="pages.tx_sgnews_comments_enable"> + <source><![CDATA[Enable comments on this page]]></source> + </trans-unit> <trans-unit id="plugin.flexForm"> <source><![CDATA[Settings]]></source> </trans-unit> diff --git a/Resources/Private/Templates/SingleView/SingleView.html b/Resources/Private/Templates/SingleView/SingleView.html index e41e216fb8066430e905713e216397888239bf95..b9f098afd3e8a431d37aefe3ae39537627407321 100644 --- a/Resources/Private/Templates/SingleView/SingleView.html +++ b/Resources/Private/Templates/SingleView/SingleView.html @@ -224,14 +224,16 @@ </div> </section> - <section class="content"> - <div class="container"> - <div class="tx-sgnews-single-comments"> - <div id="comments" class="tx-sgnews-comments-inner"> - <f:cObject typoscriptObjectPath="lib.sgCommentsIndex" /> + <f:if condition="{newsMetaData.news.enableComments}"> + <section class="content"> + <div class="container"> + <div class="tx-sgnews-single-comments"> + <div id="comments" class="tx-sgnews-comments-inner"> + <f:cObject typoscriptObjectPath="lib.sgCommentsIndex" /> + </div> </div> </div> - </div> - </section> + </section> + </f:if> </f:alias> </f:section> diff --git a/ext_tables.sql b/ext_tables.sql index cf5da4c80990185b37ed49d6cb7afb4664e7e346..82c2a724a4ac75c867450c6e421a505080acd1cf 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -10,6 +10,7 @@ CREATE TABLE pages ( tx_sgnews_location mediumtext, tx_sgnews_date_end int(10) unsigned DEFAULT '0' NOT NULL, tx_sgnews_content_from_another_page int(11) unsigned DEFAULT '0' NOT NULL, + tx_sgnews_comments_enable tinyint(4) unsigned DEFAULT '1' NOT NULL, KEY news_author (tx_sgnews_news_author) );