TYPO3 v9的RouteEnhancer indexed_search

时间:2019-04-25 10:06:54

标签: typo3 url-routing typo3-9.x

我想从indexed_search重写搜索结果的URL,但是它不起作用。什么都没发生。 我已经在RouteEnhancer之后添加到我的config.yaml

routeEnhancers:
  IndexedSearchPlugin:
    type: Extbase
    limitToPages:
      - 38
    extension: IndexedSearch
    plugin: Pi2
    routes:
      - routePath: '/page/{page}'
        _controller: 'Search::search'
        _arguments:
          page: '@widget_0/currentPage'
    defaultController: 'Search::search'
    defaults:
      page: '0'
    requirements:
      page: \d+
    aspects:
      page:
        type: StaticRangeMapper
        start: '1'
        end: '100'

也许有人有主意吗?

3 个答案:

答案 0 :(得分:0)

我很少使用index_search,但快速浏览了页面浏览器的代码。用于indexed_search的页面浏览器是使用表单和JavaScript而非直接链接完成的。因此,当在页面浏览器中单击页面时,将设置一个隐藏字段并提交表单。路由增强器仅适用于TYPO3生成的链接。我不确定为什么要这样做,但是如果不更改页面浏览器的工作方式,就无法增强这些URL。

答案 1 :(得分:0)

Rudy Gnodde是对的:没有'page'参数,因此您无需进行配置。

只需使用以下routeEnhancer即可拥有一个URL,如www.domain.com/my-search-page/search,其中my-search-page是包含indexed_search插件的页面。

routeEnhancers:
  IndexedSearchPlugin:
    type: Extbase
    extension: IndexedSearch
    plugin: Pi2
    routes:
      - routePath: '/search'
        _controller: 'Search::search'
    defaultController: 'Search::search'

答案 2 :(得分:0)

我想这取决于您要美化的东西。就我而言,我使用此config.yaml来获取搜索结果的干净网址(搜索字段由TypoScript生成),并且能够通过查询进行搜索。

假设我们在页面https:example.de/search/上放置了indexed_search插件。

现在从任何带有搜索字段的页面进行搜索都将产生此uri:
https:example.de/search/results

只需使用该uri,您就可以深层链接到特殊的搜索结果(在这里我们正在寻找“ lorem”):
https:example.de/search/query/lorem

routeEnhancers:
  IndexedSearchPlugin:
    type: Extbase
    namespace: tx_indexedsearch_pi2
    routes:
      - routePath: '/results'
        _controller: 'Search::search'
        _action: 'search::search'
      - routePath: '/query/{search/sword}'
        _controller: 'Search::search'
        _action: 'search::search'
        requirements:
          - search/sword: '[^/=?]*'
    defaultController: 'Search::search'
    defaultAction: 'search::search'

至少在TYPO3 v10.4.8中,这确实对我有用(无需测试分页或高级搜索)。

相关问题