Routing¶
Routing can be used to rewrite URLs. In this section you will learn how to rewrite the partner rating URLs using Routing Enhancers and Aspects. TYPO3 Explained has a chapter Introduction to routing that you can read if you are not familiar with the concept yet. You will no longer need third party extensions like RealURL or CoolUri to rewrite and beautify your URLs.
Automatic route enhancer configuration¶
By default, this extension automatically adds a Route Enhancer configuration in the following format:
1routeEnhancers:
2 PartnerRating:
3 type: Extbase
4 extension: PartnerRating
5 plugin: Pi1
6 routes:
7 -
8 routePath: /
9 _controller: 'Rating::list'
10 -
11 routePath: '/{department}'
12 _controller: 'Rating::show'
13 _arguments:
14 department: department
15 defaultController: 'Rating::list'
16 aspects:
17 department:
18 type: PersistedAliasMapper
19 tableName: tx_partnerrating_domain_model_department
20 routeFieldName: slug
This configuration is loaded in the background via the SiteConfigurationLoadedEvent
event. If you do not need to take individual deviations into account in the Route
Enhancer configuration, you do not need to worry about routing. Otherwise, continue
with the following chapter.
Please note that this automatism only works if no route enhancer has been defined
in your site configuration under the identifier PartnerRating
.
Customised rewriting of URLs with Partner Rating parameters¶
On setting up your page you should already have created a site configuration. You can do this in the backend module Site Managements > Sites.
Your site configuration will be stored in
/config/sites/<your_identifier>/config.yaml
. The following
configurations have to be applied to this file, if you like to add some customizations
like limiting to certain pages with propert limitToPages
.
Any URL parameters can be rewritten with the Routing Enhancers and Aspects.
These are added manually in the config.yaml
:
Add the following YAML configuration under routeEnhancers
:
/config/sites/<your_identifier>/config.yaml
¶ 1routeEnhancers:
2 PartnerRating:
3 type: Extbase
4 limitToPages:
5 - 1
6 extension: PartnerRating
7 plugin: Pi1
8 routes:
9 -
10 routePath: /
11 _controller: 'Rating::list'
12 -
13 routePath: '/{department}'
14 _controller: 'Rating::show'
15 _arguments:
16 department: department
17 defaultController: 'Rating::list'
18 aspects:
19 department:
20 type: PersistedAliasMapper
21 tableName: tx_partnerrating_domain_model_department
22 routeFieldName: slug