Skip to content
Snippets Groups Projects
Verified Commit ec1b1a90 authored by Kevin Ditscheid's avatar Kevin Ditscheid
Browse files

[TASK] Cleanup code and use ViewHelper in SIngleView

parent bd018a37
No related branches found
No related tags found
1 merge request!41[TASK] Add related news by tag or category
...@@ -26,12 +26,8 @@ namespace SGalinski\SgNews\Domain\Model; ...@@ -26,12 +26,8 @@ namespace SGalinski\SgNews\Domain\Model;
* This copyright notice MUST APPEAR in all copies of the script! * 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\Generic\LazyLoadingProxy;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage; use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
/** /**
* News * News
...@@ -101,20 +97,6 @@ class News extends CategoryAndNews { ...@@ -101,20 +97,6 @@ class News extends CategoryAndNews {
*/ */
protected $contentFromAnotherPage = 0; protected $contentFromAnotherPage = 0;
/**
* @var ConfigurationManager
*/
protected $configurationManager;
/**
* Inject the configuration manager
*
* @param ConfigurationManager $configurationManager
*/
public function injectConfigurationManager(ConfigurationManager $configurationManager) {
$this->configurationManager = $configurationManager;
}
/** /**
* Constructor * Constructor
*/ */
...@@ -200,12 +182,6 @@ class News extends CategoryAndNews { ...@@ -200,12 +182,6 @@ class News extends CategoryAndNews {
$this->relatedNews->_loadRealInstance(); $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; return $this->relatedNews;
} }
......
...@@ -26,7 +26,6 @@ namespace SGalinski\SgNews\Domain\Repository; ...@@ -26,7 +26,6 @@ namespace SGalinski\SgNews\Domain\Repository;
* This copyright notice MUST APPEAR in all copies of the script! * This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/ ***************************************************************/
use SGalinski\SgNews\Domain\Model\Author;
use SGalinski\SgNews\Domain\Model\News; use SGalinski\SgNews\Domain\Model\News;
use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\ConnectionPool;
......
...@@ -19,11 +19,5 @@ plugin.tx_sgnews { ...@@ -19,11 +19,5 @@ plugin.tx_sgnews {
# sort direction (DESC / ASC) # sort direction (DESC / ASC)
sortDirection = DESC 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
} }
} }
...@@ -109,12 +109,6 @@ plugin.tx_sgnews { ...@@ -109,12 +109,6 @@ plugin.tx_sgnews {
# The logo value for the structured data implementation (see single view template) # The logo value for the structured data implementation (see single view template)
publisherLogo = 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 { features {
......
...@@ -179,21 +179,40 @@ ...@@ -179,21 +179,40 @@
</div> </div>
<f:if condition="{newsMetaData.news.relatedNews}"> <f:if condition="{newsMetaData.news.relatedNews}">
<div class="tx-sgnews-single-related"> <f:then>
<h3> <div class="tx-sgnews-single-related">
<f:translate key="frontend.singleview.relatedArticles" /> <h3>
</h3> <f:translate key="frontend.singleview.relatedArticles" />
</h3>
<ul>
<f:for each="{newsMetaData.news.relatedNews}" as="relatedNewsEntry"> <ul>
<li> <f:for each="{newsMetaData.news.relatedNews}" as="relatedNewsEntry">
<a href="{f:uri.page(pageUid: '{relatedNewsEntry.uid}')}"> <li>
{relatedNewsEntry.subtitleWithFallbackToTitle} <a href="{f:uri.page(pageUid: '{relatedNewsEntry.uid}')}">
</a> {relatedNewsEntry.subtitleWithFallbackToTitle}
</li> </a>
</f:for> </li>
</ul> </f:for>
</div> </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> </f:if>
</div> </div>
</div> </div>
......
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