Problems with routeEnhancers and Slash PageTypeSuffix

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
JanWohlfeil
Posts: 3
Joined: 23 Apr 2021, 07:26

Problems with routeEnhancers and Slash PageTypeSuffix

Post by JanWohlfeil » 23 Apr 2021, 07:59

TYPO3: 10.4.15
Aimeos: 20.10.7
Mac with ddev/Docker PHP 7.4, mariadb: 10.2

Hello all,

I have major problems with Aimeos when I add a slash at the end of the url in the site config like this:

Code: Select all

routeEnhancers:
  PageTypeSuffix:
    type: PageType
    default: /
    index: ''
    map:
      /: 0
Then at least the calls for Stock and Count do not work anymore, they look like this:
http://domain.de/de/gutscheine-und-shop ... ][47]=2016 (type= fehlt)

Convert this to
http://domain.de/de/gutscheine-und-shop ... =191351524

Remove "/" after "/stock" and add "type=" the call works. But I don't understand why this happens.

Here is the complete siteconfig:

Code: Select all

base: 'http://livedomain.de/'
baseVariants:
  -
    base: 'http://domain.de/'
    condition: 'applicationContext == "Development"'
errorHandling:
  -
    errorCode: 404
    errorHandler: Page
    errorContentSource: 't3://page?uid=1'
languages:
  -
    title: Deutsch
    enabled: true
    languageId: 0
    base: /de/
    typo3Language: de
    locale: de_DE.UTF-8
    iso-639-1: de
    navigationTitle: Deutsch
    hreflang: de-de
    direction: ltr
    flag: de
    websiteTitle: ''
  -
    title: english
    enabled: true
    base: /en/
    typo3Language: default
    locale: en_GB.UTF-8
    iso-639-1: en
    websiteTitle: ''
    navigationTitle: English
    hreflang: en-GB
    direction: ''
    fallbackType: strict
    fallbacks: '0'
    flag: gb
    languageId: 1
  -
    title: français
    enabled: true
    base: /fr/
    typo3Language: fr
    locale: fr_FR.UTF-8
    iso-639-1: fr
    websiteTitle: ''
    navigationTitle: Français
    hreflang: fr-FR
    direction: ''
    fallbackType: strict
    fallbacks: '0'
    flag: fr
    languageId: 2
rootPageId: 1
routeEnhancers:
  PageTypeSuffix:
    type: PageType
    default: /
    index: ''
    map:
      /: 0
      sitemap.xml: 1533906435
      yoast-snippetpreview.json: 1480321830
  Aimeos:
    type: Extbase
    namespace: ai
    defaultController: 'Catalog::list'
    routes:
      -
        routePath: '/pin/{pin_action}/{pin_id}/{d_name}'
        _controller: 'Catalog::detail'
      -
        routePath: '/history/{his_action}/{his_id}'
        _controller: 'Account::history'
      -
        routePath: '/watch/{wat_action}/{wat_id}'
        _controller: 'Account::watch'
      -
        routePath: '/watch/{wat_action}'
        _controller: 'Account::watch'
      -
        routePath: '/fav/{fav_action}/{fav_id}'
        _controller: 'Account::favorite'
      -
        routePath: '/fav/{fav_action}'
        _controller: 'Account::favorite'
      -
        routePath: '/c/{f_name}~{f_catid}'
        _controller: 'Catalog::list'
      -
        routePath: '/p/{d_name}/{d_prodid}/{d_pos}'
        _controller: 'Catalog::detail'
      -
        routePath: '/d/{d_name}/{d_pos}'
        _controller: 'Catalog::detail'
      -
        routePath: '/lt/{l_type}'
        _controller: 'Catalog::list'
      -
        routePath: '/lp/{l_page}'
        _controller: 'Catalog::list'
      -
        routePath: '/ls/{f_sort}/{l_page}'
        _controller: 'Catalog::list'
      -
        routePath: '/l/{f_sort}'
        _controller: 'Catalog::list'
      -
        routePath: '/b/{b_action}'
        _controller: 'Basket::index'
      -
        routePath: '/co/{c_step}'
        _controller: 'Checkout::index'
    defaults:
      b_action: ''
      c_step: ''
      f_sort: 'name'
      d_pos: ''
#   News:
#     type: Extbase
#     extension: News
#     plugin: Pi1
#     routes:
#       -
#         routePath: '/{news-title}'
#         _controller: 'News::detail'
#         _arguments:
#           news-title: news
#     aspects:
#       news-title:
#         type: PersistedPatternMapper
#         tableName: tx_news_domain_model_news
#         routeFieldPattern: '^(?P<path_segment>.+)-(?P<uid>\d+)$'
#         routeFieldResult: '{path_segment}-{uid}'
websiteTitle: ''

The whole thing can also be reproduced with the standard TYPO3 Aimeos template. I hope someone has an idea.

Thanks :-)

User avatar
aimeos
Administrator
Posts: 7873
Joined: 01 Jan 1970, 00:00

Re: Problems with routeEnhancers and Slash PageTypeSuffix

Post by aimeos » 27 Apr 2021, 05:25

Guess that these lines:

Code: Select all

    type: PageType
    default: /
    map:
      /: 0
Overwrite the page type used by the count, suggest and stock URLs:
https://github.com/aimeos/aimeos-typo3/ ... xt#L35-L37
Which changes the content type to application/javascript and remove any HTML inserted by TYPO3 into default pages:
https://github.com/aimeos/aimeos-typo3/ ... xt#L60-L76
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
JanWohlfeil
Posts: 3
Joined: 23 Apr 2021, 07:26

Re: Problems with routeEnhancers and Slash PageTypeSuffix

Post by JanWohlfeil » 27 Apr 2021, 13:48

Yes correct, but i need them, because i need a trailing slash in all urls. Any ideas?

User avatar
JanWohlfeil
Posts: 3
Joined: 23 Apr 2021, 07:26

Re: Problems with routeEnhancers and Slash PageTypeSuffix

Post by JanWohlfeil » 05 May 2021, 10:07

For anybody else struggling with this:
1. adding trailing slashes in .htaccess is not a good idea in this case
2. adding stock page type in the site's config.yaml is your friend (last line):

Code: Select all

routeEnhancers:
  ....
  PageTypeSuffix:
    type: PageType
    default: /
    index: ''
    map:
      /: 0
      sitemap.xml: 1533906435
      yoast-snippetpreview.json: 1480321830
      stock: 191351524
:D

Post Reply