diff --git a/Classes/Controller/ListByCategoryController.php b/Classes/Controller/ListByCategoryController.php index 184c8c555f23a4c4ff3b1b7504a83707d185fb8c..417baecf26f4c71330e4ae19855664c18e6dcc7a 100644 --- a/Classes/Controller/ListByCategoryController.php +++ b/Classes/Controller/ListByCategoryController.php @@ -129,6 +129,9 @@ class ListByCategoryController extends AbstractController { if (isset($this->settings['tags'])) { $tagUids = GeneralUtility::intExplode(',', $this->settings['tags'], TRUE); } + + HeaderMetaDataService::addPageNumberToCanonical($currentPageBrowserPage); + foreach ($categoryUids as $categoryUid) { if ($categoryUid > 0) { $filterByCategories = TRUE; diff --git a/Classes/Controller/OverviewController.php b/Classes/Controller/OverviewController.php index a8e4476ab4f852aa7f2d068561ec84c7b108bb92..11361cd06c7c775b8fa0c73f1b9be1c72a8d4cb0 100644 --- a/Classes/Controller/OverviewController.php +++ b/Classes/Controller/OverviewController.php @@ -34,6 +34,7 @@ use SGalinski\SgNews\Domain\Repository\TagRepository; use SGalinski\SgNews\Domain\Service\NewsService; use SGalinski\SgNews\Service\ConfigurationService; use SGalinski\SgNews\Service\HeaderMetaDataService; +use SGalinski\SgSeo\Service\HeadTagService; use TYPO3\CMS\Core\Http\ImmediateResponseException; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -147,6 +148,8 @@ class OverviewController extends AbstractController { $isCategoryFiltered = $useAllFilters || (int) $this->settings['groupBy'] === 1; $isTagFiltered = $useAllFilters || (int) $this->settings['groupBy'] === 2; + HeaderMetaDataService::addPageNumberToCanonical($currentPageBrowserPage); + // Get tag pid $tagPid = (int) $this->settings['tagPid']; if (!$tagPid) { @@ -434,6 +437,8 @@ class OverviewController extends AbstractController { $newsPerPage = (int) $this->settings['newsLimit']; $offset = $this->calculatePaginationOffset($currentPageBrowserPage, $newsPerPage); + HeaderMetaDataService::addPageNumberToCanonical($currentPageBrowserPage); + $newsCount = 0; $categoryIds = NULL; $categoriesById = []; diff --git a/Classes/Service/HeaderMetaDataService.php b/Classes/Service/HeaderMetaDataService.php index ddf5d530c93591084d02da6169acc4e040cf4a1d..8eb4508e4db5b855e48bc5a833b3c8ed7895a7ea 100644 --- a/Classes/Service/HeaderMetaDataService.php +++ b/Classes/Service/HeaderMetaDataService.php @@ -26,7 +26,11 @@ namespace SGalinski\SgNews\Service; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ +use SGalinski\SgSeo\Service\HeadTagService; +use TYPO3\CMS\Core\Package\Exception; use TYPO3\CMS\Core\Resource\FileReference; +use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; /** @@ -56,4 +60,31 @@ class HeaderMetaDataService { $typoScriptController = $GLOBALS['TSFE']; $typoScriptController->page['og_image_path_by_extension'] = $file; } + + /** + * Adds the page number to the canonical + * + * @param int $currentPage + * @return void + * @throws Exception + */ + public static function addPageNumberToCanonical(int $currentPage): void { + if ($currentPage < 1) { + return; + } + + if (version_compare(ExtensionManagementUtility::getExtensionVersion('sg_seo'), '5.0.0', '>=')) { + $headTagService = GeneralUtility::makeInstance( + HeadTagService::class, + FALSE, + '', + '', + '&tx_sgnews_pagebrowser[currentPage]=' . $currentPage + ); + $headTagService->execute(); + } else { + $GLOBALS['TSFE']->page['extensionArgumentsForCanonicalAndHrefLang'] = + '&tx_sgnews_pagebrowser[currentPage]=' . $currentPage; + } + } } diff --git a/Configuration/FlexForms/Latest.xml b/Configuration/FlexForms/Latest.xml index 9592c27ca3da78f52cb479b9399c136a3b60c802..0dbfbdd9332586fd51f0275c5033bfa3da725649 100644 --- a/Configuration/FlexForms/Latest.xml +++ b/Configuration/FlexForms/Latest.xml @@ -107,6 +107,16 @@ </config> </TCEforms> </settings.sortBy> + + <settings.newsLink> + <TCEforms> + <label>LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:plugin.flexForm.newsLink</label> + <config> + <type>input</type> + <renderType>inputLink</renderType> + </config> + </TCEforms> + </settings.newsLink> </el> </ROOT> </main> diff --git a/Configuration/Routes/config.yaml b/Configuration/Routes/config.yaml index 63f43e4a9b2c56279a5b009f1e89375e7e3e747e..05af95b4700be97a346a39868557812c1d5426b8 100644 --- a/Configuration/Routes/config.yaml +++ b/Configuration/Routes/config.yaml @@ -3,7 +3,13 @@ routeEnhancers: type: Plugin namespace: tx_sgnews_pagebrowser routePath: '/{localizedSegment}/{currentPage}' + defaults: + currentPage: '0' aspects: + currentPage: + type: StaticRangeMapper + start: '1' + end: '1000' localizedSegment: type: LocaleModifier default: page diff --git a/README.md b/README.md index d4a25ba0780ea166aee0998e5b5a0b7b9c731da0..09323fcaa0349055ac13b4b94239da470a30c5ef 100644 --- a/README.md +++ b/README.md @@ -307,6 +307,30 @@ pagebrowser.settings { } ``` +Example route enhancers with a static range for the page number to be able to generate URLs without additional cHash parameter + +```YAML +routeEnhancers: + PageBrowserNews: + type: Plugin + namespace: tx_sgnews_pagebrowser + routePath: '/{localizedSegment}/{currentPage}' + defaults: + currentPage: '0' + aspects: + currentPage: + type: StaticRangeMapper + start: '1' + end: '1000' + localizedSegment: + type: LocaleModifier + default: page + localeMap: + - + locale: 'de_DE.*' + value: page +``` + --- ###### addLike diff --git a/Resources/Private/Language/de.locallang_db.xlf b/Resources/Private/Language/de.locallang_db.xlf index 10d21c38c025ad2e9731b8d48b500ae8578ab2b9..ac5bb3ccf996190a8fd4a4ec408b05b592680158 100644 --- a/Resources/Private/Language/de.locallang_db.xlf +++ b/Resources/Private/Language/de.locallang_db.xlf @@ -165,6 +165,10 @@ <source><![CDATA[News Author]]></source> <target><![CDATA[News Autor]]></target> </trans-unit> + <trans-unit id="plugin.flexForm.newsLink" approved="yes"> + <source><![CDATA[Link]]></source> + <target><![CDATA[Link]]></target> + </trans-unit> <trans-unit id="plugin.flexForm.orderInPageTree" approved="yes"> <source><![CDATA[Order in pagetree (Only one category allowed)]]></source> <target><![CDATA[Reihenfolge im Seitenbaum (Nur eine Kategorie erlaubt)]]></target> diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index 4d42520c1b82b563b95e9ebf859d6c61489b0978..67892996bb1af7b12f54706c1edffaa8c48ddc7e 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -126,6 +126,9 @@ <trans-unit id="plugin.flexForm.newsAuthor"> <source><![CDATA[News Author]]></source> </trans-unit> + <trans-unit id="plugin.flexForm.newsLink"> + <source><![CDATA[Link]]></source> + </trans-unit> <trans-unit id="plugin.flexForm.orderInPageTree"> <source><![CDATA[Order in pagetree (Only one category allowed)]]></source> </trans-unit> diff --git a/Resources/Public/Sass/_layout-content.scss b/Resources/Public/Sass/_layout-content.scss index bad2609bea8adc7f095e8a99c4bbb8f82508e796..6e5706e11d7d273433bc239d5f08f8c80cd9061b 100644 --- a/Resources/Public/Sass/_layout-content.scss +++ b/Resources/Public/Sass/_layout-content.scss @@ -36,33 +36,33 @@ $sg-news-chevron-color: var(--component-color-primary-background, $black-base); display: none; position: relative; bottom: -10px; - width: auto !important; // stylelint-disable-line + width: auto !important; // stylelint-disable-line @media (min-width: $screen-sm) { display: block; } } - &[data-current-columns="3"] { + &[data-current-columns='3'] { .sg-slide-dots__indicator { - &:not(:nth-child(3n+1)) { + &:not(:nth-child(3n + 1)) { display: none; } } - .sg-slide:not(:nth-child(3n+1)) { + .sg-slide:not(:nth-child(3n + 1)) { border-left: 1px solid $sg-news-border-color; } } - &[data-current-columns="2"] { + &[data-current-columns='2'] { .sg-slide-dots__indicator { - &:not(:nth-child(2n+1)) { + &:not(:nth-child(2n + 1)) { display: none; } } - .sg-slide:not(:nth-child(2n+1)) { + .sg-slide:not(:nth-child(2n + 1)) { border-left: 1px solid $sg-news-border-color; } } @@ -76,7 +76,7 @@ $sg-news-chevron-color: var(--component-color-primary-background, $black-base); .sg-slide-news-content { margin-bottom: 16px; - padding: 0 50px + padding: 0 50px; } .tx-sgnews-teaser-description { @@ -90,7 +90,7 @@ $sg-news-chevron-color: var(--component-color-primary-background, $black-base); display: block; content: ''; width: $sg-news-headline-underline-width; - height: #{$sg-news-headline-underline-width / 6}; + height: calc(#{$sg-news-headline-underline-width} / 6); background: $sg-news-foreground-color; } } diff --git a/composer.json b/composer.json index 8ced56d988cfe6df39a70134a45783213c2a8151..8a99161821611727bce5f91bd6fea526b35ad5e6 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "license": [ "GPL-2.0-or-later" ], - "version": "9.8.3", + "version": "9.8.6", "support": { }, "repositories": [ diff --git a/ext_emconf.php b/ext_emconf.php index c02387d4a7ad7e4f0874a0f223a30748f9d8d46c..b8310a9d8c5ef8daf58fd187335b81484430ec8b 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -19,7 +19,7 @@ $EM_CONF['sg_news'] = [ 'modify_tables' => '', 'clearCacheOnLoad' => 0, 'lockType' => '', - 'version' => '9.8.3', + 'version' => '9.8.6', 'constraints' => [ 'depends' => [ 'typo3' => '10.4.0-11.5.99',