我在TYPO3 9.5.11上使用新闻扩展和无限滚动插件时遇到问题。
我正在寻找的是设置 2 个无限滚动 :一个列出每个新闻,另一个按类别列出新闻(使用按类别列表(。它有效,但是当我按类别列出我的新闻时,我无法像其他滚动那样获得可读的 URL(例如,我得到*categorie/page-2?tx_news_pi1[action]=list&tx_news_pi1[controller]=News&tx_news_pi1[overwriteDemand][categories]=3&cHash=6ff5f6ee014fec754b5453d9c4afdcc1*
而不是categorie/nameofthecategory/page-X
(。我希望它足够清楚。
这是我的配置.yaml :
routeEnhancers:
News:
type: Extbase
extension: News
plugin: Pi1
routes:
-
routePath: '/{news-title}'
_controller: 'News::detail'
_arguments:
news-title: news
-
routePath: '/{category-name}'
_controller: 'News::list'
_arguments:
category-name: overwriteDemand/categories
-
routePath: '/{tag-name}'
_controller: 'News::list'
_arguments:
tag-name: overwriteDemand/tags
defaultController: 'News::list'
defaults:
page: '0'
aspects:
news-title:
type: PersistedAliasMapper
tableName: tx_news_domain_model_news
routeFieldName: path_segment
category-name:
type: PersistedAliasMapper
tableName: sys_category
routeFieldName: slug
tag-name:
type: PersistedAliasMapper
tableName: tx_news_domain_model_tag
routeFieldName: slug
NewsList:
type: Plugin
routePath: '/page-{@widget_0/currentPage}'
namespace: 'tx_news_pi1'
aspects:
'@widget_0/currentPage':
type: StaticRangeMapper
start: '1'
end: '1000'
有人知道如何设置吗?
谢谢! :-(
编辑:好的,所以我发现使用此config.yaml有点工作:
routeEnhancers:
News:
type: Extbase
extension: News
plugin: Pi1
routes:
-
routePath: '/{page}'
_controller: 'News::list'
_arguments:
page: '@widget_0/currentPage'
-
routePath: '/{news-title}'
_controller: 'News::detail'
_arguments:
news-title: news
- routePath: '/{category-name}'
_controller: 'News::list'
_arguments:
category-name: overwriteDemand/categories
-
routePath: '/{category-name}/{page}'
_controller: 'News::list'
_arguments:
category-name: overwriteDemand/categories
page: '@widget_0/currentPage'
defaultController: 'News::list'
defaults:
page: '1'
requirements:
page: 'd+'
aspects:
news-title:
type: PersistedAliasMapper
tableName: tx_news_domain_model_news
routeFieldName: path_segment
category-name:
type: PersistedAliasMapper
tableName: sys_category
routeFieldName: slug
page:
type: StaticRangeMapper
start: '1'
end: '100'
此设置的问题是我遇到了这里解释的错误:错误 #86895 - 路由增强器无法正确用于分页小部件。这意味着在我的主页上,如果我把网址放在*/2
并加载第一页,我会得到一个不正确的URL。无论出于何种原因,我都没有在我的类别过滤页面中遇到它......
我尝试应用Forge中提到的补丁,不幸的是没有成功。
好的,所以我终于找到了解决方案。我完全忘记了您可以指定指定路由工作的页面。这是最终版本:
routeEnhancers:
News:
type: Extbase
extension: News
plugin: Pi1
routes:
-
routePath: '/{news-title}'
_controller: 'News::detail'
_arguments:
news-title: news
- routePath: '/{category-name}'
_controller: 'News::list'
_arguments:
category-name: overwriteDemand/categories
-
routePath: '/{category-name}/{page}'
_controller: 'News::list'
_arguments:
category-name: overwriteDemand/categories
page: '@widget_0/currentPage'
defaultController: 'News::list'
defaults:
page: '1'
requirements:
page: 'd+'
aspects:
news-title:
type: PersistedAliasMapper
tableName: tx_news_domain_model_news
routeFieldName: path_segment
category-name:
type: PersistedAliasMapper
tableName: sys_category
routeFieldName: slug
page:
type: StaticRangeMapper
start: '1'
end: '1000'
NewsList:
type: Plugin
limitToPages: [3] #(3 is my main's page pid)
routePath: '/{@widget_0/currentPage}'
namespace: 'tx_news_pi1'
aspects:
'@widget_0/currentPage':
type: StaticRangeMapper
start: '1'
end: '1000'
这样,基于插件的路由器可以在主页上工作(即使我从第 2 页到第 1 页(,我可以对该类别使用基于 EXTBase 的路由。