georgringer / news

TYPO3 Extension news
GNU General Public License v2.0
260 stars 352 forks source link

Category menu and news list breaking on same page with frontend routing activated #2250

Open fsuter opened 8 months ago

fsuter commented 8 months ago

Bug Report

Current Behavior I have a page with two news plugins installed: the category menu (CategoryList) and the standard news list (Pi1). When I click on a category, I get the following error:

The controller "News" is not allowed by plugin "CategoryList". Please check for TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.

When there's no frontend routing configuration (i.e. no speaking URLs), this does not happen.

I have the following frontend routing configuration:

routeEnhancers:
  NewsPlugin:
    type: Extbase
    namespace: tx_news_pi1
    defaultController: 'News::list'
    routes:
      -
        routePath: '/article/{news-title}'
        _controller: 'News::detail'
        _arguments:
          news-title: news
      -
        routePath: '/cat/{category-name}'
        _controller: 'News::list'
        _arguments:
          category-name: overwriteDemand/categories
    aspects:
      news-title:
        type: NewsTitle
      category-name:
        type: NewsCategory

I have tried the configuration from the documentation: https://docs.typo3.org/p/georgringer/news/11.2/en-us/Tutorials/BestPractice/Routing/Index.html#basic-setup-including-categories-tags-and-the-rss-atom-feed and many other variants, all to no avail.

Digging into the Extbase RequestBuilder, where the error happens, I can see that the default values are as expected (pointing to the CategoryController) but they are overridden by the query parameters (which point to the "list" action of the NewsController).

I'm not sure whether this is an Extbase issue, a routing (configuration) issue or really a "news" issue, but at least the extension documentation seem to indicate that two plugins can co-exist on the same page, whereas my current experience shows the contrary.

Expected behavior/output Being able to the the category menu and the news list on the same page. The category menu should show the active category and the news list should be filtered according to the selected category.

Environment

jramke commented 7 months ago

Im experiencing the same issue with active routeEnhancers, but i dont get the same error message. In my case somehow the detailAction is called an then caught by the handleNoNewsFoundError function.

jramke commented 7 months ago

I ended up using two different routeEnhancers. One for the detail controller and one for all views with the list controller. Somehow news detail and category list where overwriting each other or something.

routeEnhancers:
  NewsDetail:
    type: Extbase
    extension: News
    plugin: Pi1
    limitToPages:
      - 22
      - 54
    routes:
      -
        routePath: '/{news-title}'
        _controller: 'News::detail'
        _arguments:
          news-title: news
    defaultController: 'News::detail'
    aspects:
      news-title:
        type: NewsTitle
  News:
    type: Extbase
    extension: News
    plugin: Pi1
    limitToPages:
      - 9
      # - 22
      - 23
      - 26
      - 14
    routes:
      -
        routePath: '/seite-{page}'
        _controller: 'News::list'
        _arguments:
          page: 'currentPage'
      - 
        routePath: '/{category-name}'
        _controller: 'News::list'
        _arguments:
          category-name: overwriteDemand/categories
      # -
      #   routePath: '/{news-title}'
      #   _controller: 'News::detail'
      #   _arguments:
      #     news-title: news
      - 
        routePath: '/{tag-name}'
        _controller: 'News::list'
        _arguments:
          tag-name: overwriteDemand/tags
    defaultController: 'News::list'
    defaults:
      page: '0'
    aspects:
      # news-title:
      #   type: NewsTitle
      page:
        type: StaticRangeMapper
        start: '1'
        end: '100'
      category-name:
        type: NewsCategory
      tag-name:
        type: NewsTag
fsuter commented 6 months ago

The above configuration does not solve the issue for me. Then again, as @jramke said, he does not have the same error message...

klodeckl commented 5 months ago

I got the same problem, it did cost me really a lot of time. The order is important and the aspect types matter. This is my configuration which works without problems:

  News:
    type: Extbase
    limitToPages:
      - 172
      - 521
      - 3147
      - 2578
      - 635
    extension: News
    plugin: Pi1
    routes:
      - routePath: '/{news-title}'
        _controller: 'News::detail'
        _arguments:
          news-title: news
      - routePath: '/{tag-name}'
        _controller: 'News::list'
        _arguments:
          tag-name: overwriteDemand/tags
      - routePath: '/{tag-name}/{page-label}-{page}'
        _controller: 'News::list'
        _arguments:
          tag-name: overwriteDemand/tags
          page: 'currentPage'
      - routePath: '/'
        _controller: 'News::list'
      - routePath: '/{page-label}-{page}'
        _controller: 'News::list'
        _arguments:
          page: 'currentPage'
      - 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'
    aspects:
      news-title:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: path_segment
      page:
        type: StaticRangeMapper
        start: '1'
        end: '100'
      page-label:
        type: LocaleModifier
        default: 'page'
        localeMap:
          - locale: 'en_GB.*'
            value: 'page'
          - locale: 'de_DE.*'
            value: 'seite'
      category-name:
        type: NewsCategory
      tag-name:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_tag
        routeFieldName: slug

If the order is changed and/or the aspect type it won’t work for either title, category or tag. I think I really tried every combination. Is this a core or a news issue?

fsuter commented 5 months ago

That made me very hopeful, but it still doesn't work for me.

Environment (updated)

TYPO3 version(s): 12.4.10
news version: 11.3.0
Is your TYPO3 installation set up with Composer (Composer Mode): yes
OS: OSX 14.2
klodeckl commented 5 months ago

Then maybe something is different between TYPO3 11 and 12. What exactly doesn’t work in your case? Did you adjust the ids in limitToPages? It seems that the order is really important and also the used aspect types. Before I switched to news 11 and non-composer mode (I think the important change is update news 10 to 11) ordering and aspect type didn’t matter, no issues.

klodeckl commented 5 months ago

I just realized my config has one issue: in case of a link with no news/category/tag matching 404 is not fired but message „no news found“. So it seems the system filters news list with no found category or tag. It seems to be a news ext issue in the repository and no core issue.

fsuter commented 5 months ago

I did adjust limitToPages and I respected the ordering you suggested. Indeed maybe something is different between TYPO3 11 and 12. I feel like it is rather an Extbase issue (with a relationship to frontend routing).

klodeckl commented 4 months ago

After updating news from 11.3 to 11.4.1 I had to change the ordering again to get everything working. Here my current working setup:

  News:
    type: Extbase
    limitToPages:
      - 172
      - 521
      - 3147
      - 2578
      - 635
      - 4900
      - 1325
    extension: News
    plugin: Pi1
    routes:
      - routePath: '/{news-title}'
        _controller: 'News::detail'
        _arguments:
          news-title: news
      - routePath: '/{tag-name}/{page-label}-{page}'
        _controller: 'News::list'
        _arguments:
          tag-name: overwriteDemand/tags
          page: 'currentPage'
      - routePath: '/{category-name}/{page-label}-{page}'
        _controller: 'News::list'
        _arguments:
          category-name: overwriteDemand/categories
          page: 'currentPage'
      - routePath: '/{tag-name}'
        _controller: 'News::list'
        _arguments:
          tag-name: overwriteDemand/tags
      - routePath: '/'
        _controller: 'News::list'
      - routePath: '/{page-label}-{page}'
        _controller: 'News::list'
        _arguments:
          page: 'currentPage'
      - routePath: '/{category-name}'
        _controller: 'News::list'
        _arguments:
          category-name: overwriteDemand/categories
    defaultController: 'News::list'
    defaults:
      page: '0'
    aspects:
      news-title:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: path_segment
      page:
        type: StaticRangeMapper
        start: '1'
        end: '100'
      page-label:
        type: LocaleModifier
        default: 'page'
        localeMap:
          - locale: 'en_GB.*'
            value: 'page'
          - locale: 'de_DE.*'
            value: 'seite'
      category-name:
        type: NewsCategory
      tag-name:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_tag
        routeFieldName: slug
wdraghwendra commented 3 months ago

I am facing same problem in typo3 version 12.4.x . Any solution on this please suggest?