如何从网址中排除详细信息页面的路径段?

时间:2019-04-11 06:35:48

标签: typo3 tx-news typo3-9.x

在Typo3 v9中,我已经按照here的说明安装了路由。

但是,URL中始终存在详细信息页面的路径段。

即使我在“口语URL路径段”字段中输入“月度新闻”,新闻的网址也为www.domain.com/details/news-of-the-month

但是我想要www.domain.com/news-of-the-month

有可能吗?

这是我的config.yaml:

rootPageId: 1
base: /
baseVariants: {  }
languages:
  -
    title: Deutsch
    enabled: true
    languageId: '0'
    base: /
    typo3Language: de
    locale: de_DE.UTF-8
    iso-639-1: de
    navigationTitle: ''
    hreflang: de-DE
    direction: ''
    flag: de
errorHandling: {  }
routes: {  }
routeEnhancers:
  NewsPlugin:
    type: Extbase
    limitToPages:
      - 39
      - 40
      - 41
    extension: News
    plugin: Pi1
    routes:
      - { routePath: '/{news_title}', _controller: 'News::detail', _arguments: {'news_title': 'news'} }
    defaultController: 'News::detail'
    aspects:
      news_title:
        type: PersistedAliasMapper
        tableName: 'tx_news_domain_model_news'
        routeFieldName: 'path_segment'
        routeValuePrefix: '/'
      page:
        type: StaticRangeMapper
        start: '1'
        end: '100'
  DateMenu:
    type: Extbase
    extension: News
    plugin: Pi1
    routes:
      # Pagination:
      - routePath: '/page/{page}'
        _controller: 'News::list'
        _arguments:
          page: '@widget_0/currentPage'
        requirements:
          page: '\d+'
      - routePath: '/{news-title}'
        _controller: 'News::detail'
        _arguments:
          news-title: news
      # Date year:
      - routePath: '/dateFilter/{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: '/dateFilter/{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: '/dateFilter/{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: '/dateFilter/{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: ''
    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:
          '01': '01'
          '02': '02'
          '03': '03'
          '04': '04'
          '05': '05'
          '06': '06'
          '07': '07'
          '08': '08'
          '09': '09'
          '10': '10'
          '11': '11'
          '12': '12'
      date-year:
        type: StaticRangeMapper
        start: '2000'
        end: '2030'

1 个答案:

答案 0 :(得分:0)

您至少需要一个额外的路径段(例如“ details”),因为TYPO3需要使用详细信息视图插件查找页面,但您的详细信息视图不在您的根页面上。在根页面上使用详细信息视图时,您可能只希望在选择新闻时显示它(通过TypoScript条件):

[page["uid"] == 1 && (request.getQueryParams()['tx_news_pi1'])['news'] > 0]
# enable news plugin with detail view
[end]