I have a sitemap, generated by tx_seo for an extension "myext".
The sitemap works, but the links generated look like:
http://domain.local/detail?tx_myext_pi1[action]=list&tx_myext_pi1[controller]=Read&tx_myext_pi1[uid]=333&cHash=4d4...
while they should look like:
http://domain.local/detail/title-of-record-333
I have already defined an appropriate routing in sites/mysite/config.yaml.
Is there a way to use the routeEnhancers of config.yaml to get readable urls in the sitemap as well?
Of course, I could build a new SitemapDataProvider-Class and create the links there. But this is duplicate code, and might have subtle differences to the solution in config.yaml. So my preferred way would be to use the mechanism defined in config.yaml - but I can't find any hint how that could possibly work.
Here is the configuration I use in config.yaml:
routeEnhancers:
PageTypeSuffix:
type: PageType
map:
sitemap.xml: 1533906435
MyPlugin:
type: Extbase
extension: MyExt
plugin: Pi1
defaultController: 'Mycontroller::list'
limitToPages: [12345]
routes:
- routePath: '/mypath/{question}/{tab}/{theme}'
_controller: 'Mycontroller::show'
aspects:
question:
type: PersistedAliasMapper
tableName: tx_myext_domain_model_question
routeFieldName: path_segment
theme:
type: PersistedAliasMapper
tableName: tx_myext_domain_model_theme
routeFieldName: name
tab:
type: StaticRangeMapper
start: '1'
end: '3'
The configuration currently only configures a single route which expects three arguments:
The sitemap generates a link containing only a uid argument. Therefore there is no route configured that can be used. You would either need to configure a route for only uid argument. Or you need to adjust the proper building of the URLs for your sitemap to include the arguments question, tab and theme instead of uid.
So I guess you need proper configuration of your sitemap, following: https://docs.typo3.org/m/typo3/reference-coreapi/12.4/en-us/ApiOverview/Seo/XmlSitemap.html#for-records There you can configure the url to build for each record, no need to build a custom PHP class.
This is the example taken from docs for completeness in case the link might no longer include the example:
plugin.tx_seo {
config {
<sitemapType> {
sitemaps {
<unique key> {
provider = TYPO3\CMS\Seo\XmlSitemap\RecordsXmlSitemapDataProvider
config {
table = news_table
sortField = sorting
lastModifiedField = tstamp
changeFreqField = news_changefreq
priorityField = news_priority
additionalWhere = AND (no_index = 0 OR no_follow = 0)
pid = <page id('s) containing news records>
recursive = <number of subpage levels taken into account beyond the pid page. (default: 0)>
url {
pageId = <your detail page id>
fieldToParameterMap {
uid = tx_extension_pi1[news]
}
additionalGetParameters {
tx_extension_pi1.controller = News
tx_extension_pi1.action = detail
}
}
}
}
}
}
}
}