news icon indicating copy to clipboard operation
news copied to clipboard

addQueryString in combination with routing

Open georgringer opened this issue 2 years ago • 6 comments

WIth commit https://github.com/georgringer/news/commit/9297aa5602e167273e53910c0db81bb6fe102a9a the addQueryString:1 has been added which doesnt work with routing for categories.

See also https://stackoverflow.com/questions/69856851/typo3-10-tx-news-version-9-0-0-pagination-of-category-news-lists/69879670?noredirect=1#comment123567446_69879670

georgringer avatar Nov 10 '21 06:11 georgringer

The news related part of my routeenhancer config causing the issue is as following:

routeEnhancers:
  NewsPlugin:
    type: Extbase
    extension: News
    plugin: Pi1
    routes:
      - routePath: '/'
        _controller: 'News::list'
      - routePath: '/{page-label}-{page}'
        _controller: 'News::list'
        _arguments:
          page: '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-label}-{page}'
        _controller: 'News::list'
        _arguments:
          category-name: overwriteDemand/categories
          page: 'currentPage'
    defaultController: 'News::list'
    defaults:
      page: '0'
    requirements:
      news_title: '^[a-zA-Z0-9].*$'
      page: \d+
    aspects:
      news-title:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: path_segment
      page:
        type: StaticRangeMapper
        start: '1'
        end: '200'
      category-name:
        type: PersistedAliasMapper
        tableName: sys_category
        routeFieldName: slug
      page-label:
        type: LocaleModifier
        default: 'page'
        localeMap:
          - locale: 'de_DE.*'
            value: 'seite'

To get category news pages running, I have to remove the two category_name routpaths, but also the page-label/page routepath.

WulfGW avatar Nov 11 '21 09:11 WulfGW

I had the same issue with 9.2 on TYPO3 10.4.25. The solution in #1715 (adding addQueryStringMethod: 'GET') worked for me.

sir-gawain avatar May 11 '22 08:05 sir-gawain

TYPO3 11.5.4 / News 9.4.0 same problem. In the paginator links without specifying a category. addQueryString:1 do not work :(

filippoff avatar Jun 16 '22 13:06 filippoff

route:

routeEnhancers:
  News:
    type: Extbase
    limitToPages:
      - 14
      - 557
    extension: News
    plugin: Pi1
    routes:
      -
        routePath: '/'
        _controller: 'News::list'
      -
        routePath: '/{page}'
        _controller: 'News::list'
        _arguments:
          page: 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: currentPage
      -
        routePath: '/{tag-name}'
        _controller: 'News::list'
        _arguments:
          tag-name: overwriteDemand/tags
      -
        routePath: '/{date-year}'
        _controller: 'News::list'
        _arguments:
          date-month: overwriteDemand/month
          date-year: overwriteDemand/year
          page: currentPage
        requirements:
          date-year: \d+
      -
        routePath: '/{date-year}/{page}'
        _controller: 'News::list'
        _arguments:
          date-year: overwriteDemand/year
          page: currentPage
        requirements:
          date-year: \d+
          page: \d+
      -
        routePath: '/{date-year}/{date-month}'
        _controller: 'News::list'
        _arguments:
          date-month: overwriteDemand/month
          date-year: overwriteDemand/year
          page: currentPage
        requirements:
          date-month: \d+
          date-year: \d+
      -
        routePath: '/{date-year}/{date-month}/{page}'
        _controller: 'News::list'
        _arguments:
          date-month: overwriteDemand/month
          date-year: overwriteDemand/year
          page: currentPage
        requirements:
          date-month: \d+
          date-year: \d+
          page: \d+
    defaultController: 'News::list'
    defaults:
      page: '1'
      year: ''
      month: ''
      requirements:
        news_title: '^[a-zA-Z0-9].*$'
        page: \d+
    aspects:
      news-title:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: path_segment
      page:
        type: StaticRangeMapper
        start: '1'
        end: '100'
      category-name:
        type: PersistedAliasMapper
        tableName: sys_category
        routeFieldName: slug
      tag-name:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_tag
        routeFieldName: slug
      date-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'
      date-year:
        type: StaticRangeMapper
        start: '2000'
        end: '2030'
  PageTypeSuffix:
    type: PageType
    default: ''
    index: ''
    map:
      /: 0
      feed.xml: 9818
      calendar.ical: 9819
      sitemap.xml: 1533906435

filippoff avatar Jun 16 '22 13:06 filippoff

Still a problem in TYPO3 v12 and workaround (adding addQueryStringMethod: 'GET') not working any more because "addQueryStringMethod" has been removed from TYPO3 core :(

Btw: Routing is not the problem, without any routing configuration for EXT:news, the url in pagination doesn't contain the category parameter. Explanation with examples: After using the category filter, resulting url is ?tx_news_pi1[overwriteDemand][categories]=10&cHash=xyz Link in pagination is ?tx_news_pi1[controller]=News&tx_news_pi1[currentPage]=2&cHash=xyz

SventB avatar Dec 30 '23 23:12 SventB

Ok, problem found, use

addQueryString="untrusted"

See https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Feature-98488-AdditionalSettingForTypolinkOptionAddQueryString.html:

Setting typolink.addQueryString = untrusted adds any given query parameters just as it was done in TYPO3 v11 when using typolink.addQueryString = 1.

But still, the problems with speaking urls are not solved: When activating routing again, the link in pagination is

?tx_news_pi1[action]=detail&tx_news_pi1[controller]=News&tx_news_pi1[currentPage]=3&cHash=1aa3439b5ceab1915b48dd89732e6147

I'm wondering where action=detail is from and why there's no category.

SventB avatar Dec 31 '23 00:12 SventB