JKB
JKB

Reputation: 510

TYPO3 Route Enhancers: List (with optional pagination and filter) + Detail on same page

Currently, i've got list-view and detail-view (both with optional category-parameter) on same page using two distinct route definitions as following:

routeEnhancers:
  RecipeListDetail:
    type: Extbase
    limitToPages: [2]
    extension: Myext
    plugin: Pi1
    routes:
      - { routePath: '/{category_title}', _controller: 'Recipe::list', _arguments: {'category_title': 'category'} }
      - { routePath: '/{category_title}/{recipe_title}', _controller: 'Recipe::show', _arguments: {'category_title': 'category', 'recipe_title': 'recipe'} }
    defaultController: 'Recipe::show'
    aspects:
      category_title:
        type: PersistedAliasMapper
        tableName: sys_category
        routeFieldName: tx_myext_slug
      recipe_title:
        type: PersistedAliasMapper
        tableName: tx_myext_domain_model_recipe
        routeFieldName: slug         

Now i would like to extend this configuration with a (optional) pagination. So the configuration must be able to handle the following url formats:

  # List-View (optional category, optional pagination):
  /
  /category 
  /category/page-1 
  /page-1

  # Detail-View (with category):
  /category/recipe

In addition, another dedicated page exists for handling detail views of records when no category parameter is given. But thats not part of the problem as configuration is limited to another page.

UPDATE 2019-09-10: Tried to add 3 routes (as suggested by chris.berlin), one for each url variant. Removed to detail-view configuration for debugging:

  - { routePath: '/category-{category_title}/page-{page}', _controller: 'Recipe::list', _arguments: {'category_title': 'category', 'page': '@widget_0/currentPage'} }
  - { routePath: '/category-{category_title}', _controller: 'Recipe::list', _arguments: {'category_title': 'category'} }
  - { routePath: '/page-{page}', _controller: 'Recipe::list', _arguments: {'page': '@widget_0/currentPage'} }

As soon as pagination gets involved, anything seems to go wrong. E.g. pagination looses category-param after first pagination link was clicked. In addition, sometimes the wrong route seems to match. Might there be any bug in using "route enhancers + pagination + additional parameters"?

Upvotes: 2

Views: 966

Answers (3)

Mihir Bhatt
Mihir Bhatt

Reputation: 3155

You need to add addQueryStringMethod="GET" in f:widget.link like following

<f:widget.link addQueryStringMethod="GET">{page.number}</f:widget.link>

Upvotes: 0

JKB
JKB

Reputation: 510

The origin example works fine but the issue was it is neccessary to add „addQueryString“ to the paginate viewhelper.

Upvotes: 0

chris.berlin
chris.berlin

Reputation: 191

Did you try to add another route like this?

- { routePath: '/{category_title}/page/{number}'

Maybe like this it is possible to distinguish between the three routes list, list+paginated and detailview.

Upvotes: 1

Related Questions