Skip to content
Snippets Groups Projects
Commit 57c88328 authored by Johannes Kreiner's avatar Johannes Kreiner
Browse files

[BUGFIX][WIP] Add canonicals to pagination

parent bc341613
No related branches found
No related tags found
1 merge request!45Bugfix pagebrowser handling
......@@ -120,6 +120,9 @@ class ListByCategoryController extends AbstractController {
$filterByCategories = FALSE;
$categoryUids = GeneralUtility::intExplode(',', $this->settings['categories']);
$tagUids = GeneralUtility::intExplode(',', $this->settings['tags'], TRUE);
HeaderMetaDataService::addPageNumberToCanonical($currentPageBrowserPage);
foreach ($categoryUids as $categoryUid) {
if ($categoryUid > 0) {
$filterByCategories = TRUE;
......
......@@ -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;
......@@ -137,6 +138,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) {
......@@ -418,6 +421,8 @@ class OverviewController extends AbstractController {
$newsPerPage = (int) $this->settings['newsLimit'];
$offset = $this->calculatePaginationOffset($currentPageBrowserPage, $newsPerPage);
HeaderMetaDataService::addPageNumberToCanonical($currentPageBrowserPage);
$newsCount = 0;
$categoryIds = NULL;
$categoriesById = [];
......
......@@ -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;
/**
......@@ -44,4 +48,31 @@ class HeaderMetaDataService {
$typoScriptController = $GLOBALS['TSFE'];
$typoScriptController->page['og_image_path_by_extension'] = $path;
}
/**
* 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;
}
}
}
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