I want my URLs for my news detail page to look like this:
example.com/news/2019/07/22/article-name
How can I achieve this using RouteEnhancers?
Code so far:
routeEnhancers:
Detail:
type: Extbase
extension: News
plugin: Pi1
routes:
# Pagination:
- routePath: '/page-{page}'
_controller: 'News::list'
_arguments:
page: '@widget_0/currentPage'
requirements:
page: '\d+'
- routePath: '/{date-year}/{date-month}/{date-day}/{news-title}'
_controller: 'News::detail'
_arguments:
date-month: 'overwriteDemand/month'
date-year: 'overwriteDemand/year'
date-day: 'overwriteDemand/day'
news-title: news
requirements:
news-title: '\w+'
date-month: '\d+'
date-year: '\d+'
date-day: '\d+'
# Date year:
- routePath: '/{date-year}'
_controller: 'News::list'
_arguments:
date-month: 'overwriteDemand/month'
date-year: 'overwriteDemand/year'
page: '@widget_0/currentPage'
requirements:
date-year: '\d+'
# Date year + pagination:
- routePath: '/{date-year}/page-{page}'
_controller: 'News::list'
_arguments:
date-year: 'overwriteDemand/year'
page: '@widget_0/currentPage'
requirements:
date-year: '\d+'
page: '\d+'
# Date year/month:
- routePath: '/{date-year}/{date-month}'
_controller: 'News::list'
_arguments:
date-month: 'overwriteDemand/month'
date-year: 'overwriteDemand/year'
page: '@widget_0/currentPage'
requirements:
date-month: '\d+'
date-year: '\d+'
# Date year/month + pagination:
- routePath: '/{date-year}/{date-month}/page-{page}'
_controller: 'News::list'
_arguments:
date-month: 'overwriteDemand/month'
date-year: 'overwriteDemand/year'
page: '@widget_0/currentPage'
requirements:
date-month: '\d+'
date-year: '\d+'
page: '\d+'
defaultController: 'News::list'
defaults:
page: '0'
date-month: ''
date-year: ''
date-day: ''
aspects:
news-title:
type: PersistedAliasMapper
tableName: tx_news_domain_model_news
routeFieldName: path_segment
page:
type: StaticRangeMapper
start: '1'
end: '25'
date-month:
type: StaticValueMapper
map:
january: '01'
february: '02'
march: '03'
april: '04'
may: '05'
june: '06'
july: '07'
august: '08'
september: '09'
october: '10'
november: '11'
december: '12'
date-year:
type: StaticRangeMapper
start: '2000'
end: '2030'
Current output:
example.com/news/tx_news_pi1%5Baction%5D=detail&tx_news_pi1%5Bcontroller%5D=News&tx_news_pi1%5Bnews%5D=2&cHash=b38beb0089692fa008e37545c57d48dc