From 093afddc12a0d76b493c2ecccc59687c8812179b Mon Sep 17 00:00:00 2001 From: Stefan Galinski <stefan@sgalinski.de> Date: Sat, 21 Nov 2020 18:30:23 +0100 Subject: [PATCH] [BUGFIX] Fix metadata for author related pages --- Classes/Controller/NewsByAuthorController.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Classes/Controller/NewsByAuthorController.php b/Classes/Controller/NewsByAuthorController.php index 071293e..7a5f550 100644 --- a/Classes/Controller/NewsByAuthorController.php +++ b/Classes/Controller/NewsByAuthorController.php @@ -26,15 +26,16 @@ namespace SGalinski\SgNews\Controller; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ +use SGalinski\SgNews\Domain\Model\Author; +use SGalinski\SgNews\Domain\Model\Category; use SGalinski\SgNews\Domain\Model\News; use SGalinski\SgNews\Domain\Repository\AuthorRepository; use SGalinski\SgNews\Domain\Repository\CategoryRepository; use SGalinski\SgNews\Domain\Repository\NewsRepository; -use SGalinski\SgNews\Service\HeaderMetaDataService; use TYPO3\CMS\Core\Utility\GeneralUtility; /** - * Controller that handles the news single view page + * News Author List Controller */ class NewsByAuthorController extends AbstractController { /** @@ -45,7 +46,7 @@ class NewsByAuthorController extends AbstractController { * @throws \InvalidArgumentException * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException */ - public function listAction($authorId = 0) { + public function listAction($authorId = 0): void { if ($authorId) { $newsAuthorsIds[] = $authorId; } else { @@ -58,11 +59,17 @@ class NewsByAuthorController extends AbstractController { $authors = []; $authorRepository = $this->objectManager->get(AuthorRepository::class); foreach ($newsAuthorsIds as $newsAuthorsId) { + /** @var Author $author */ $author = $authorRepository->findByUid($newsAuthorsId); if (!$author) { continue; } + $GLOBALS['TSFE']->page['titlebyextension'] = $author->getName(); + $GLOBALS['TSFE']->page['description'] = \strip_tags(\substr($author->getDescription(), 0, 200)); + $GLOBALS['TSFE']->page['extensionArgumentsForCanonicalAndHrefLang'] = + '&tx_sgnews_newsbyauthor[authorId]=' . $author->getUid(); + $authors[] = $author; } @@ -88,6 +95,7 @@ class NewsByAuthorController extends AbstractController { $categoryId = $newsEntry->getPid(); if (!isset($categories[$categoryId])) { + /** @var Category $category */ $category = $categoryRepository->findByUid($categoryId); if (!$category) { continue; @@ -100,7 +108,6 @@ class NewsByAuthorController extends AbstractController { } } - $this->view->assign('newsMetaData', $newsMetaData); $this->view->assign('authors', $authors); } -- GitLab