Skip to content

Commit

Permalink
[TASK] Fix RSS feed link creation
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoBlack committed Feb 14, 2019
1 parent 3ddd82e commit 026ec8e
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 9 deletions.
10 changes: 7 additions & 3 deletions Classes/Controller/PostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,12 @@ public function injectBlogCacheService(CacheService $cacheService): void

/**
* @param ViewInterface $view
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
*/
protected function initializeView(ViewInterface $view): void
{
parent::initializeView($view);
if ($this->request->hasArgument('format') && $this->request->getArgument('format') === 'rss') {
$action = '.' . $this->request->getArgument('action');
if ($this->request->getFormat() === 'rss') {
$action = '.' . $this->request->getControllerActionName();
$arguments = [];
switch ($action) {
case '.listPostsByCategory':
Expand All @@ -120,6 +119,11 @@ protected function initializeView(ViewInterface $view): void
$arguments[] = $this->arguments['tag']->getValue()->getTitle();
}
break;
case '.listPostsByAuthor':
if (isset($this->arguments['author'])) {
$arguments[] = $this->arguments['author']->getValue()->getName();
}
break;
default:
}
$feedData = [
Expand Down
1 change: 0 additions & 1 deletion Classes/ViewHelpers/Link/ArchiveViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public function render(): string
->setUseCacheHash(true);
if ($rssFormat) {
$uriBuilder
->setFormat('rss')
->setTargetPageType($this->getTypoScriptFrontendController()->tmpl->setup['blog_rss_archive.']['typeNum']);
}
$uri = $uriBuilder->uriFor('listPostsByDate', $arguments, 'Post', 'Blog', 'Archive');
Expand Down
1 change: 0 additions & 1 deletion Classes/ViewHelpers/Link/AuthorViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ protected function getUriBuilder(int $pageUid, array $additionalParams, bool $rs
->setArguments($additionalParams);
if ($rssFormat) {
$uriBuilder
->setFormat('rss')
->setTargetPageType($this->getTypoScriptFrontendController()->tmpl->setup['blog_rss_author.']['typeNum']);
}

Expand Down
1 change: 0 additions & 1 deletion Classes/ViewHelpers/Link/CategoryViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public function render(): string
->setUseCacheHash(true);
if ($rssFormat) {
$uriBuilder
->setFormat('rss')
->setTargetPageType($this->getTypoScriptFrontendController()->tmpl->setup['blog_rss_category.']['typeNum']);
}
$uri = $uriBuilder->uriFor('listPostsByCategory', $arguments, 'Post', 'Blog', 'Category');
Expand Down
1 change: 0 additions & 1 deletion Classes/ViewHelpers/Link/TagViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public function render(): string
->setUseCacheHash(true);
if ($rssFormat) {
$uriBuilder
->setFormat('rss')
->setTargetPageType($this->getTypoScriptFrontendController()->tmpl->setup['blog_rss_tag.']['typeNum']);
}
$uri = $uriBuilder->uriFor('listPostsByTag', $arguments, 'Post', 'Blog', 'Tag');
Expand Down
5 changes: 5 additions & 0 deletions Configuration/TypoScript/Static/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ blog_rss_posts = PAGE
blog_rss_posts {
typeNum = 200
10 < tt_content.list.20.blog_posts
10.format = rss

config {
disableAllHeaderCode = 1
Expand All @@ -161,14 +162,17 @@ blog_rss_posts {
blog_rss_category < blog_rss_posts
blog_rss_category.typeNum = 210
blog_rss_category.10 < tt_content.list.20.blog_category
blog_rss_category.10.format = rss

blog_rss_tag < blog_rss_posts
blog_rss_tag.typeNum = 220
blog_rss_tag.10 < tt_content.list.20.blog_tag
blog_rss_tag.10.format = rss

blog_rss_archive < blog_rss_posts
blog_rss_archive.typeNum = 230
blog_rss_archive.10 < tt_content.list.20.blog_archive
blog_rss_archive.10.format = rss

blog_rss_comments < blog_rss_posts
blog_rss_comments.typeNum = 240
Expand All @@ -177,3 +181,4 @@ blog_rss_comments.10 < tt_content.list.20.blog_comments
blog_rss_author < blog_rss_posts
blog_rss_author.typeNum = 250
blog_rss_author.10 < tt_content.list.20.blog_authorposts
blog_rss_author.10.format = rss
6 changes: 6 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,12 @@
<trans-unit id="feed.description.listPostsByCategory" xml:space="preserve">
<source>Posts by category %s</source>
</trans-unit>
<trans-unit id="feed.title.listPostsByAuthor" xml:space="preserve">
<source>Author RSS Feed</source>
</trans-unit>
<trans-unit id="feed.description.listPostsByAuthor" xml:space="preserve">
<source>Posts by author %s</source>
</trans-unit>
<trans-unit id="feed.title.listPostsByDate" xml:space="preserve">
<source>Archive RSS Feed</source>
</trans-unit>
Expand Down
4 changes: 2 additions & 2 deletions Resources/Private/Templates/Widget/Feed.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<f:section name="content">
<h3 class="widget-title"><f:translate key="headline.rssfeed"/></h3>
<ul class="feeds">
<li><f:link.action pageUid="{settings.blogUid}" pageType="200" format="rss" action="listRecentPosts" controller="Post">Recent posts</f:link.action></li>
<li><f:link.page pageUid="{settings.blogUid}" pageType="200">Recent posts</f:link.page></li>
</ul>
</f:section>
</f:section>

0 comments on commit 026ec8e

Please sign in to comment.