[TASK] Move documentation files into 9.5 folder - part 2
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Documentation / Changelog / 9.5 / Feature-86160-PageTypeEnhancerForMappingTypeParameter.rst
1 .. include:: ../../Includes.txt
2
3 ==============================================================
4 Feature: #86160 - PageTypeEnhancer for mapping &type parameter
5 ==============================================================
6
7 See :issue:`86160`
8
9 Description
10 ===========
11
12 A new Route Enhancer is added to the newly introduced Routing functionality which allows to add
13 a suffix to the existing route (including existing other enhancers) to map a page type (GET parameter &type=)
14 to a suffix.
15
16 It is now possible to map various page types to endings.
17
18 Example TypoScript:
19
20 .. code-block:: typoscript
21
22 page = PAGE
23 page.typeNum = 0
24 page.10 = TEXT
25 page.10.value = Default page
26
27 rssfeed = PAGE
28 rssfeed.typeNum = 13
29 rssfeed.10 < plugin.tx_myplugin
30 rssfeed.config.disableAllHeaderCode = 1
31 rssfeed.config.additionalHeaders.10.header = Content-Type: xml/rss
32
33 jsonview = PAGE
34 jsonview.typeNum = 26
35 jsonview.10 = USER
36 jsonview.10.userFunc = MyVendor\MyExtension\Controller\JsonPageController->renderAction
37 jsonview.10.config.disableAllHeaderCode = 1
38 jsonview.10.config.additionalHeaders.10.header = Content-Type: application/json
39
40 Now configure the Route Enhancer in your site's :file:`config.yaml` file like this:
41
42 .. code-block:: yaml
43
44 routeEnhancers:
45 PageTypeSuffix:
46 type: PageType
47 default: ''
48 map:
49 'rss.feed': 13
50 '.json': 26
51
52
53 The :yaml:`map` allows to add a filename or a file ending and map this to a :ts:`page.typeNum` value.
54
55 It is also possible to set :yaml:`default` to e.g. ".html" to add a ".html" suffix to all default pages.
56
57 .. code-block:: yaml
58
59 routeEnhancers:
60 PageTypeSuffix:
61 type: PageType
62 default: '.json'
63 index: 'index'
64 map:
65 'rss.feed': 13
66 '.json': 26
67
68 The :yaml:`index` property is used when generating links on root-level page, thus, instead of e.g. having
69 `/en/.json` thus would then result in `/en/index.json`.
70
71 Impact
72 ======
73
74 The TYPO3 Frontend-internal `&type` parameter can now also be part of a speaking URL with a simple
75 line of configuration.
76
77 Please note that the implementation is a Decorator Enhancer, which means that the PageTypeEnhancer
78 is only there for adding suffixes to an existing route / variant, but not to substitute something
79 within the middle of a speaking URL segment.
80
81 .. index:: Frontend