[TASK] Cleanup generation of sitemap-index-URLs 48/58548/3
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Mon, 1 Oct 2018 21:34:07 +0000 (23:34 +0200)
committerBenni Mack <benni@typo3.org>
Sun, 28 Oct 2018 12:35:17 +0000 (13:35 +0100)
Use pageType-parameter from f:uri.page instead of providing
the type through additionalParams.
And don't include the page-parameter unless we are on another page
than the first one (page=0). Many DataProviders might only use one
page anyway.

Resolves: #86531
Releases: master
Change-Id: Id6f7ac8f53d03802e904ee0c946c8d0c02ee61f9
Reviewed-on: https://review.typo3.org/58548
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Jörg Bösche <typo3@joergboesche.de>
Reviewed-by: Richard Haeser <richard@maxserv.com>
Tested-by: Richard Haeser <richard@maxserv.com>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/seo/Resources/Private/Templates/XmlSitemap/Index.xml
typo3/sysext/seo/Tests/Functional/XmlSitemap/XmlSitemapIndexTest.php

index e8a23b3..1dd37a9 100644 (file)
@@ -3,7 +3,12 @@
 <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:f="http://typo3.org/ns/fluid/ViewHelpers">
     <f:for each="{sitemaps}" as="sitemap">
         <sitemap>
-            <loc><f:uri.page additionalParams="{type: type, sitemap: sitemap.key, page: sitemap.page}" absolute="true" noCacheHash="false" /></loc>
+            <f:spaceless>
+                <f:if condition="{sitemap.page}">
+                    <f:then><loc><f:uri.page pageType="{type}" additionalParams="{sitemap: sitemap.key, page: sitemap.page}" absolute="true" noCacheHash="false" /></loc></f:then>
+                    <f:else><loc><f:uri.page pageType="{type}" additionalParams="{sitemap: sitemap.key}" absolute="true" noCacheHash="false" /></loc></f:else>
+                </f:if>
+            </f:spaceless>
             <lastmod>{sitemap.lastMod -> f:format.date(format: 'c')}</lastmod>
         </sitemap>
     </f:for>
index 7d0f6d8..99e33db 100644 (file)
@@ -67,6 +67,6 @@ class XmlSitemapIndexTest extends AbstractTestCase
         $this->assertEquals(200, $response->getStatusCode());
         $this->assertArrayHasKey('Content-Length', $response->getHeaders());
         $this->assertGreaterThan(0, $response->getHeader('Content-Length')[0]);
-        $this->assertRegExp('/<loc>http:\/\/localhost\/\?page=0&amp;sitemap=pages&amp;type=1533906435&amp;cHash=[^<]+<\/loc>/', (string)$response->getBody());
+        $this->assertRegExp('/<loc>http:\/\/localhost\/\?sitemap=pages&amp;type=1533906435&amp;cHash=[^<]+<\/loc>/', (string)$response->getBody());
     }
 }