diff --git a/Classes/Domain/Model/News.php b/Classes/Domain/Model/News.php index fd90345e4a839e2c057ab9aa3225b00a2da235f3..d273fa1b68627f95da8447f31749ae9d0ac39bfa 100644 --- a/Classes/Domain/Model/News.php +++ b/Classes/Domain/Model/News.php @@ -26,12 +26,8 @@ namespace SGalinski\SgNews\Domain\Model; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ -use SGalinski\SgNews\Domain\Repository\NewsRepository; -use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy; use TYPO3\CMS\Extbase\Persistence\ObjectStorage; -use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; -use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; /** * News @@ -101,20 +97,6 @@ class News extends CategoryAndNews { */ protected $contentFromAnotherPage = 0; - /** - * @var ConfigurationManager - */ - protected $configurationManager; - - /** - * Inject the configuration manager - * - * @param ConfigurationManager $configurationManager - */ - public function injectConfigurationManager(ConfigurationManager $configurationManager) { - $this->configurationManager = $configurationManager; - } - /** * Constructor */ @@ -200,12 +182,6 @@ class News extends CategoryAndNews { $this->relatedNews->_loadRealInstance(); } - $settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS); - if ($settings['automaticRelatedNews'] && !$this->_isNew() && $this->relatedNews->count() === 0) { - $newsRepository = GeneralUtility::makeInstance(NewsRepository::class); - $this->relatedNews = $newsRepository->findRelated($this, $settings['limitRelatedNews']); - } - return $this->relatedNews; } diff --git a/Classes/Domain/Repository/NewsRepository.php b/Classes/Domain/Repository/NewsRepository.php index e09d74ed202021388ab892896c9df4e578126b33..d12d51aa645cdd8ceb35ec9f04e0fd4acc16a10d 100644 --- a/Classes/Domain/Repository/NewsRepository.php +++ b/Classes/Domain/Repository/NewsRepository.php @@ -26,7 +26,6 @@ namespace SGalinski\SgNews\Domain\Repository; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ -use SGalinski\SgNews\Domain\Model\Author; use SGalinski\SgNews\Domain\Model\News; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; diff --git a/Configuration/TypoScript/Frontend/constants.typoscript b/Configuration/TypoScript/Frontend/constants.typoscript index 6da22e82464b101d0e2f617c1952e00e7b94881a..34a9c4da599228c1cc1b6f3069b7b9a49eab04db 100644 --- a/Configuration/TypoScript/Frontend/constants.typoscript +++ b/Configuration/TypoScript/Frontend/constants.typoscript @@ -19,11 +19,5 @@ plugin.tx_sgnews { # sort direction (DESC / ASC) sortDirection = DESC - - # Enable fetching of related news by tag or category, if related news are not set manually - automaticRelatedNews = 1 - - # Set a limit for fetched related news (for no limit, set to 0) - limitRelatedNews = 5 } } diff --git a/Configuration/TypoScript/Frontend/setup.typoscript b/Configuration/TypoScript/Frontend/setup.typoscript index 1d41c089b2b11274a1deef16126d3237281b2daf..9a52fd4ef64e299d3c2fd12ce028ac75c9ebbf6a 100644 --- a/Configuration/TypoScript/Frontend/setup.typoscript +++ b/Configuration/TypoScript/Frontend/setup.typoscript @@ -109,12 +109,6 @@ plugin.tx_sgnews { # The logo value for the structured data implementation (see single view template) publisherLogo = - - # Enable fetching of related news by tag or category, if related news are not set manually - automaticRelatedNews = {$plugin.tx_sgnews.settings.automaticRelatedNews} - - # Set a limit for fetched related news (for no limit, set to 0) - limitRelatedNews = {$plugin.tx_sgnews.settings.limitRelatedNews} } features { diff --git a/Resources/Private/Templates/SingleView/SingleView.html b/Resources/Private/Templates/SingleView/SingleView.html index e41e216fb8066430e905713e216397888239bf95..5d2e817c90c7fcc4bbb53a50a2ca064e445aaa37 100644 --- a/Resources/Private/Templates/SingleView/SingleView.html +++ b/Resources/Private/Templates/SingleView/SingleView.html @@ -179,21 +179,40 @@ </div> <f:if condition="{newsMetaData.news.relatedNews}"> - <div class="tx-sgnews-single-related"> - <h3> - <f:translate key="frontend.singleview.relatedArticles" /> - </h3> - - <ul> - <f:for each="{newsMetaData.news.relatedNews}" as="relatedNewsEntry"> - <li> - <a href="{f:uri.page(pageUid: '{relatedNewsEntry.uid}')}"> - {relatedNewsEntry.subtitleWithFallbackToTitle} - </a> - </li> - </f:for> - </ul> - </div> + <f:then> + <div class="tx-sgnews-single-related"> + <h3> + <f:translate key="frontend.singleview.relatedArticles" /> + </h3> + + <ul> + <f:for each="{newsMetaData.news.relatedNews}" as="relatedNewsEntry"> + <li> + <a href="{f:uri.page(pageUid: '{relatedNewsEntry.uid}')}"> + {relatedNewsEntry.subtitleWithFallbackToTitle} + </a> + </li> + </f:for> + </ul> + </div> + </f:then> + <f:else> + <div class="tx-sgnews-single-related"> + <h3> + <f:translate key="frontend.singleview.relatedArticles" /> + </h3> + + <ul> + <sg:related news="{newsMetaData.news}" limit="5" as="relatedNewsEntry"> + <li> + <a href="{f:uri.page(pageUid: '{relatedNewsEntry.uid}')}"> + {relatedNewsEntry.subtitleWithFallbackToTitle} + </a> + </li> + </sg:related> + </ul> + </div> + </f:else> </f:if> </div> </div>