Search code examples
typo3seotypo3-10.x

Sitemap for events2


I use TYPO3 v10.4.24, events2 v7.1. and the core SEO extension tx_seo.

I configure the sitemap for events2 this way:

plugin.tx_seo {
    config {
        xmlSitemap {
            sitemaps {
                events2 {
                    provider = TYPO3\CMS\Seo\XmlSitemap\RecordsXmlSitemapDataProvider
                    config {
                        table =  tx_events2_domain_model_event
                        sortField = tstamp
                        lastModifiedField = tstamp
                        pid = 2061
                        recursive = 2
                        url {
                            pageId = 917 //PageID Detail Page
                            fieldToParameterMap {
                                uid = tx_events2_events[event]
                            }
                            additionalGetParameters {
                                tx_events2_events.controller = Day
                                tx_events2_events.action = show
                            }
                            useCacheHash = 1
                        }
                    }
                }
            }
        }
    }
}

The sitemap is generated and I can show the detail view. Google accepts the sitemap, too. But the URLs are ugly because the route enhancer is not used. This is my configuration of the route enhancer.

Events2Plugin:
type: Extbase
extension: Events2
plugin: Events
routes:
  - { routePath: '', _controller: 'Day::list' }
  - { routePath: '/{date}/{event_title}', _controller: 'Day::show', _arguments: { date: 'timestamp', event_title: 'event' }}
  - { routePath: '/events/{date}', _controller: 'Day::showByTimestamp', _arguments: { date: 'timestamp' }}
  - { routePath: '/{location}', _controller: 'Location::show', _arguments: { location: 'location' }}
  - { routePath: '/listpage-{page}', _controller: 'Day::list', _arguments: { page: '@widget_0/currentPage' }}
defaultController: 'Day::list'
defaults:
  page: '0'
requirements:
  date: '\d+-\d+-\d+_\d+'
  event_title: '^[a-zA-Z0-9\-_]+$'
aspects:
  date:
    type: TimestampMapper
    format: Y-m-d_Hi
  event_title:
    type: PersistedAliasMapper
    tableName: tx_events2_domain_model_event
    routeFieldName: path_segment
  location:
    type: PersistedAliasMapper
    tableName: tx_events2_domain_model_location
    routeFieldName: slug
  page:
    type: StaticRangeMapper
    start: '1'
    end: '100'

What can I do that the route enhancer is used as with other extensions.


Solution

  • Your RouteEnhancer configuration for detail view requires a {date}. You only add action and controller to URI in Sitemap configuration.

    Please add

    tx_events2_events.timestamp = 0

    to section „additionalGetParameters“