Skip to content
Snippets Groups Projects
Commit 093afddc authored by Stefan Galinski's avatar Stefan Galinski :video_game:
Browse files

[BUGFIX] Fix metadata for author related pages

parent 5a5e18d4
No related branches found
No related tags found
No related merge requests found
...@@ -26,15 +26,16 @@ namespace SGalinski\SgNews\Controller; ...@@ -26,15 +26,16 @@ namespace SGalinski\SgNews\Controller;
* 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\Category;
use SGalinski\SgNews\Domain\Model\News; use SGalinski\SgNews\Domain\Model\News;
use SGalinski\SgNews\Domain\Repository\AuthorRepository; use SGalinski\SgNews\Domain\Repository\AuthorRepository;
use SGalinski\SgNews\Domain\Repository\CategoryRepository; use SGalinski\SgNews\Domain\Repository\CategoryRepository;
use SGalinski\SgNews\Domain\Repository\NewsRepository; use SGalinski\SgNews\Domain\Repository\NewsRepository;
use SGalinski\SgNews\Service\HeaderMetaDataService;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
/** /**
* Controller that handles the news single view page * News Author List Controller
*/ */
class NewsByAuthorController extends AbstractController { class NewsByAuthorController extends AbstractController {
/** /**
...@@ -45,7 +46,7 @@ class NewsByAuthorController extends AbstractController { ...@@ -45,7 +46,7 @@ class NewsByAuthorController extends AbstractController {
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/ */
public function listAction($authorId = 0) { public function listAction($authorId = 0): void {
if ($authorId) { if ($authorId) {
$newsAuthorsIds[] = $authorId; $newsAuthorsIds[] = $authorId;
} else { } else {
...@@ -58,11 +59,17 @@ class NewsByAuthorController extends AbstractController { ...@@ -58,11 +59,17 @@ class NewsByAuthorController extends AbstractController {
$authors = []; $authors = [];
$authorRepository = $this->objectManager->get(AuthorRepository::class); $authorRepository = $this->objectManager->get(AuthorRepository::class);
foreach ($newsAuthorsIds as $newsAuthorsId) { foreach ($newsAuthorsIds as $newsAuthorsId) {
/** @var Author $author */
$author = $authorRepository->findByUid($newsAuthorsId); $author = $authorRepository->findByUid($newsAuthorsId);
if (!$author) { if (!$author) {
continue; 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; $authors[] = $author;
} }
...@@ -88,6 +95,7 @@ class NewsByAuthorController extends AbstractController { ...@@ -88,6 +95,7 @@ class NewsByAuthorController extends AbstractController {
$categoryId = $newsEntry->getPid(); $categoryId = $newsEntry->getPid();
if (!isset($categories[$categoryId])) { if (!isset($categories[$categoryId])) {
/** @var Category $category */
$category = $categoryRepository->findByUid($categoryId); $category = $categoryRepository->findByUid($categoryId);
if (!$category) { if (!$category) {
continue; continue;
...@@ -100,7 +108,6 @@ class NewsByAuthorController extends AbstractController { ...@@ -100,7 +108,6 @@ class NewsByAuthorController extends AbstractController {
} }
} }
$this->view->assign('newsMetaData', $newsMetaData); $this->view->assign('newsMetaData', $newsMetaData);
$this->view->assign('authors', $authors); $this->view->assign('authors', $authors);
} }
......
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