[英]How to handle news categories in route enhancers (TYPO3 v9)
I configured some route enhancers for the news plugin: 我为新闻插件配置了一些路由增强器:
routeEnhancers:
NewsPlugin:
type: Extbase
limitToPages: [3]
extension: News
plugin: Pi1
routes:
- { routePath: '/{news_title}', _controller: 'News::detail', _arguments: {'news_title': 'news'} }
- { routePath: '/tag/{tag_name}', _controller: 'News::list', _arguments: {'tag_name': 'overwriteDemand/tags'}}
- { routePath: '/category/{category_name}', _controller: 'News::list', _arguments: {'category_name': 'overwriteDemand/categories'}}
defaultController: 'News::list'
aspects:
news_title:
type: PersistedAliasMapper
tableName: 'tx_news_domain_model_news'
routeFieldName: 'path_segment'
For the category view I get now URL like www.mydomain.com/category/2/?cHash=1234567889
对于类别视图,我现在获得URL,如
www.mydomain.com/category/2/?cHash=1234567889
Threee questions: (1): Howto get rid of the cHash? Threee问题:(1):如何摆脱cHash? This is not SEO friendly.
这不是SEO友好的。
(2): Howto use the category title instead of the category uid? (2):如何使用类别标题而不是类别uid? I tried to add an aspect:
我试图添加一个方面:
category_name:
type: PersistedAliasMapper
tableName: 'sys_category'
routeFieldName: 'path_segment'
But without success, I got an unspecific error message. 但是没有成功,我收到了一个不确定的错误消息。
(3) How to get a translated URL like www.mydomain.com/de/kategorie/...
? (3)如何获得翻译后的URL,例如
www.mydomain.com/de/kategorie/...
?
Any hints welcome. 任何提示欢迎。
The other day I found the following configuration, which incorporates all aspects of the routeEnhancers for ext:news: 前几天,我发现了以下配置,其中包含ext:news的routeEnhancers的所有方面:
routeEnhancers:
PageTypeSuffix:
type: PageType
default: '/'
index: '/'
map:
'/': 0
NewsPlugin:
type: Extbase
extension: News
plugin: Pi1
limitToPages: [33,59]
routes:
# Detail view:
- routePath: '/{news_title}'
_controller: 'News::detail'
_arguments: {'news_title': 'news'}
# Categories:
- routePath: '/{category}'
_controller: 'News::list'
_arguments: {'category': 'overwriteDemand/categories'}
# Tags:
- routePath: '/{tag_name}'
_controller: 'News::list'
_arguments: {'tag_name': 'overwriteDemand/tags'}
# Pagination:
- routePath: '/{page}'
_controller: 'News::list'
_arguments: {'page': '@widget_0/currentPage'}
# Archive:
- routePath: '/{localized_archive}/{year}/{month}'
_controller: 'News::archive'
# Date:
- routePath: '/{year}-{month}'
_controller: 'News::list'
_arguments:
year: overwriteDemand/year
month: overwriteDemand/month
defaultController: 'News::list'
defaults:
page: '0'
year: ''
month: ''
requirements:
page: '\d+'
news_title: '^[a-zA-Z0-9].*$'
aspects:
page:
type: StaticRangeMapper
start: '1'
end: '100'
news_title:
type: PersistedPatternMapper
tableName: tx_news_domain_model_news
routeFieldPattern: '^(?P<path_segment>.+)$'
routeFieldResult: '{path_segment}'
category:
type: PersistedAliasMapper
tableName: 'sys_category'
routeFieldName: 'title'
tag_name:
type: PersistedAliasMapper
tableName: 'tx_news_domain_model_tag'
routeFieldName: 'title'
localized_archive:
type: LocaleModifier
default: 'archive'
routeFieldName: 'title'
localeMap:
- languageId: 'de_.*'
value: 'archiv'
- languageId: 'fr_.*'
value: 'archives'
year:
type: StaticRangeMapper
start: '1970'
end: '2099'
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
localeMap:
- locale: 'de_.*'
map:
januar: '01'
februar: '02'
maerz: '03'
april: '04'
mai: '05'
juni: '06'
juli: '07'
august: '08'
september: '09'
oktober: 10
november: 11
dezember: 12
- locale: 'fr_.*'
map:
janvier: '01'
février: '02'
mars: '03'
avril: '04'
mai: '05'
juin: '06'
juillet: '07'
aout: '08'
septembre: '09'
octobre: 10
novembre: 11
décembre: 12
Credits: Scopestyle who answered on stackoverflow . 鸣谢: Scopestyle ,他在stackoverflow上进行了回答。
The above configuration is a modified version of Georg Ringer, which you will find here . 上面的配置是Georg Ringer的修改版,您可以在此处找到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.