[英]Infinite Scroll, pagination and routes
我在 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/page-2?tx_news_pi1[action]=list&tx_news_pi1[controller]=News&tx_news_pi1[overwriteDemand][categories]=3&cHash=6ff5f6ee014fec754b5453d9c4afdcc1*
categorie/nameofthecategory/page-X
)。 我希望它足夠清楚。
這是我的 config.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-routeEnhancer 不能正確用於分頁小部件。 這意味着在我的主頁上,如果我輸入 url */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 的路由。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.