georgringer / news

TYPO3 Extension news
GNU General Public License v2.0
263 stars 357 forks source link

addQueryString in combination with routing #1640

Open georgringer opened 2 years ago

georgringer commented 2 years ago

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

WulfGW commented 2 years ago

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.

sir-gawain commented 2 years ago

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

filippoff commented 2 years ago

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

filippoff commented 2 years ago

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
SventB commented 8 months ago

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 commented 8 months ago

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.

gpazout commented 3 weeks ago

Still a Problem in Typo3 v12.4.17. @georgringer any updates on this issue?

As @SventB describes, it is working without route enhancing. However, if route enhancing is a requirement for someones project, just changing addQueryString from 1 to 'untrusted' in the pagination partial is not sufficient enough, unfortunately.

WulfGW commented 3 weeks ago

Since page-label aspect got removed in route enhancing, everything is working fine in my installation (Typo3 v12.4.18 / news 11.4.2).

The route enhancing regarding news:

NewsPlugin: type: Extbase extension: News plugin: Pi1 routes:

Am 14.08.2024 um 15:01 schrieb gpazout:

Still a Problem in Typo3 v12.4.17. @georgringer https://github.com/georgringer any updates on this issue?

As @SventB https://github.com/SventB describes, it is working without route enhancing. However, if route enhancing is a requirement for someones project, just changing |addQueryString| from |1| to |'untrusted'| in the pagination partial is not sufficient enough, unfortunately.

— Reply to this email directly, view it on GitHub https://github.com/georgringer/news/issues/1640#issuecomment-2288679281, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWLQGVNHGOZ3W2VML3RWASTZRNILRAVCNFSM6AAAAABMQJVRGKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBYGY3TSMRYGE. You are receiving this because you commented.Message ID: @.***>

gpazout commented 2 weeks ago

Since page-label aspect got removed in route enhancing, everything is working fine in my installation (Typo3 v12.4.18 / news 11.4.2). The route enhancing regarding news: NewsPlugin: type: Extbase extension: News plugin: Pi1 routes: - routePath: '/' _controller: 'News::list' - routePath: '/page-{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-{page}' _controller: 'News::list' _arguments: category-name: overwriteDemand/categories page: 'currentPage' defaultController: 'News::list' 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 Am 14.08.2024 um 15:01 schrieb gpazout: Still a Problem in Typo3 v12.4.17. @georgringer https://github.com/georgringer any updates on this issue? As @SventB https://github.com/SventB describes, it is working without* route enhancing. However, if route enhancing is a requirement for someones project, just changing |addQueryString| from |1| to |'untrusted'| in the pagination partial is not sufficient enough, unfortunately. — Reply to this email directly, view it on GitHub <#1640 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWLQGVNHGOZ3W2VML3RWASTZRNILRAVCNFSM6AAAAABMQJVRGKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBYGY3TSMRYGE. You are receiving this because you commented.Message ID: @.***>

@WulfGW Thank you su much for the reply! Unfortunately this doesn't really solve anything for me. Maybe I messed up the settings of the plugin? Or maybe we are talking about different things.

So what I want to do is have a page, lets say https://mydomain.com/news/, with two news plugins:

With your site-config, all news from all category are rendered, no matter what category I select in the frontend.

The exptected result would be:

Is that the same thing you wanted to achieve?

WulfGW commented 2 weeks ago

As @gpazout commented

Unfortunately this doesn't really solve anything for me. Maybe I messed up the settings of the plugin? Or maybe we are talking about different things.

You described the expected results from category list and news list plugins. Exactly that works in my installation (at least with standard pagination). You can check it on my site: https://duisburg.gay-web.info/news

Maybe your problem has to do with plugin setting. But I don´t be the expert. Sorry!

Am 19.08.2024 um 14:32 schrieb gpazout:

Since page-label aspect got removed in route enhancing, everything
is working fine in my installation (Typo3 v12.4.18 / news 11.4.2).
The route enhancing regarding news: NewsPlugin: type: Extbase
extension: News plugin: Pi1 routes: - routePath: '/' _controller:
'News::list' - routePath: '/page-{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-{page}' _controller: 'News::list' _arguments:
category-name: overwriteDemand/categories page: 'currentPage'
defaultController: 'News::list' 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 Am 14.08.2024 um 15:01 schrieb
gpazout:
… <#>
Still a Problem in Typo3 v12.4.17. @georgringer
<https://github.com/georgringer> https://github.com/georgringer
<https://github.com/georgringer> any updates on this issue? As
@SventB <https://github.com/SventB> https://github.com/SventB
<https://github.com/SventB> describes, it is working /without/ route
enhancing. However, if route enhancing is a requirement for someones
project, just changing |addQueryString| from |1| to |'untrusted'| in
the pagination partial is not sufficient enough, unfortunately. —
Reply to this email directly, view it on GitHub <#1640 (comment)
<https://github.com/georgringer/news/issues/1640#issuecomment-2288679281>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWLQGVNHGOZ3W2VML3RWASTZRNILRAVCNFSM6AAAAABMQJVRGKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBYGY3TSMRYGE <https://github.com/notifications/unsubscribe-auth/AWLQGVNHGOZ3W2VML3RWASTZRNILRAVCNFSM6AAAAABMQJVRGKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBYGY3TSMRYGE>. You are receiving this because you commented.Message ID: /*@*/./**>

@WulfGW https://github.com/WulfGW Thank you su much for the reply! Unfortunately this doesn't really solve anything for me. Maybe I messed up the settings of the plugin? Or maybe we are talking about different things.

So what I want to do is have a page, lets say |https://mydomain.com/news/|, with two news plugins:

With your site-config, all news from all category are rendered, no matter what category I select in the frontend.

The exptected result would be:

— Reply to this email directly, view it on GitHub https://github.com/georgringer/news/issues/1640#issuecomment-2296463999, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWLQGVPYIGUKWSCFJL4OX4LZSHQWLAVCNFSM6AAAAABMQJVRGKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJWGQ3DGOJZHE. You are receiving this because you were mentioned.Message ID: @.***>