nhovratov / jobfair

5 stars 4 forks source link

Routing in TYPO3 9.5.31 does not work - any ideas? #3

Closed Shentao83 closed 2 years ago

Shentao83 commented 2 years ago

Hey there,

maybe I am just stupid, but I cant seem to get this to work. I feel like I am missing something:

  Jobfair:
    type: Extbase
    limitToPages:
      - 562
    extension: Jobfair
    plugin: Pi1
    routes:
      -
        routePath: '/{job_title}'
        _controller: 'Job::show'
        _arguments:
          job_title: job
    defaultController: 'Job::show'
    aspects:
      job_title:
        type: PersistedAliasMapper
        tableName: tx_jobfair_domain_model_job
        routeFieldName: slug

With this setup, the job list will be shown correctly with all the links. When I click on a link, I only see the homepage and not the job details. The link itself looks fine. If I replace routeFieldName: slug with _routeFieldName: jobtitle the job details will be shown correclty, but the URL is not okay of course.

Here is my setup: TYPO3 9.5.31, Jobfair 3.0.1, Detail page has ID 562. All jobs have a slug generated.

The basically same routeEnhancer for tx_news does work though and I have no idea why it is not working...

nhovratov commented 2 years ago

Have you tried adding the homepage to "limitToPages"?

Shentao83 commented 2 years ago

Hey there,

thank you for your input and for updating the extension in the first place! I have added the homepage to "limitToPages", but the effect is the same. I have just noticed that I am not being redirected to the homepage - I receive a 404 error, I just have not noticed that in my original post. Sorry about that!

I just don't understand why the job is being shown with _jobtitle but throws a 404 when I use slug :-(

image

Shentao83 commented 2 years ago

I have found the solution! It took me a while to find it. Here is my solution:

This problem only happens, if you store the jobs in a folder that are not in the same webroot (see screenshot). In this case the jobs should be used in website A (ID1) and website B (243).

image

Here is the corresponding ticket to this issue: https://forge.typo3.org/issues/91397

In short, you need to set this: _$GLOBALS['TCA']['tx_jobfair_domain_modeljob']['columns']['slug']['config']['eval'] = 'uniqueInPid'; or this _$GLOBALS['TCA']['tx_jobfair_domain_modeljob']['columns']['slug']['config']['eval'] = 'unique';

The latter better in most cases, I guess.

nhovratov commented 2 years ago

@Shentao83 Oh, yes I had the same problem in another project some while ago. Thanks for posting the solution!