Project

General

Profile

Bug #87817

Updated by Philipp Seiler about 5 years ago

* Define a RouteEnhancer for a certain page type: 
 <pre>routeEnhancers: 
   PageTypeSuffix: 
     type: PageType 
     default: '' 
     map: 
       foo: 1234</pre> 

 * Call some method that uses _TYPO3\CMS\Frontend\Typolink\PageLinkBuilder_, including using _TYPO3\CMS\Frontend\Typolink\PageLinkBuilder_ with a typeNum as parameter. defined. 
 <pre><f:uri.page pageType="{type}" additionalParams="{sitemap: sitemap.key, page: sitemap.page}" absolute="true" noCacheHash="false" /> 
 $uri = $uriBuilder->setTargetPageUid($pageUid)->setTargetPageType($pageType)->build();</pre> 

 * The typeNum used in the example code above should is NOT be registered in the RouteEnhancers. E.g. '5678' in respect to fit the defined RouteEnhancer above. 

 * TYPO3 then tries to use uses _\TYPO3\CMS\Core\Routing\Enhancer\PageTypeDecorator_ to add the defined page type in the RouteEnhancers to the URL, although altough for the selected typeNum ('5678') there is no RouteEnhancer defined. 
 * This leads to method _decorateForGeneration()_ removing the typeNum: 
 <pre>$deflatedParameters = $existingRoute->getOption('deflatedParameters') ?? $parameters; 
 if (isset($deflatedParameters['type'])) { 
	 unset($deflatedParameters['type']); 
	 $existingRoute->setOption( 
		 'deflatedParameters', 
		 $deflatedParameters 
	 ); 
 }</pre> 

 * Results in a link without typeNum added to it. 



 I stumbled across this, when defining a RouteEnhancer for a typeNum I used in a plugin. I also had the TYPO3 seo-extension installed, which defines the typeNum 1533906435 for getting the sitemaps. However the sitmap extension URLs didn't create valid URLs link with typeNums, the typeNum, and were therefore useless. 

 A quick fix is, to also add the typeNum defined by the seo-extension to the RouteEnhancers: 
 <pre>routeEnhancers: 
   PageTypeSuffix: 
     type: PageType 
     default: '' 
     map: 
       foo: 1234 
       sitemap: 1533906435</pre>

Back