Bug #95766
openRouting across extensions
Added by Sven Burkert about 3 years ago. Updated over 1 year ago.
0%
Description
I can't believe TYPO3 has this limitation but it seems so: has every route to be unique across all plugins of all extensions?
Given:- Extension EXT:news with a news record with title "foo"
- Extension EXT:myext with a record with title "foo"
- News record is shown on url /news/details/foo/
- Record is shown on url /myext/details/foo/
- News record is shown
- Record of EXT:myext isn't found
The controller action of EXT:myext is called with "null" instead of the object. When switching the routeEnhancers configuration in the site configuration (configuration EXT:news on last position) the record of EXT:myext is shown, but the news record not.
Updated by Christoph Lehmann about 3 years ago
Does it work for you with limitToPages ?
Updated by Sven Burkert about 3 years ago
Yes, but this isn't a solution for pages where editors can use the plugin on every page they want to.
Updated by Christoph Lehmann over 2 years ago
Maybe this helps you: https://gist.github.com/christophlehmann/48b6f5e752f3d2cf4c2c077f5ac5b9b1
Updated by Sven Burkert over 2 years ago
Thank you, this could help, nice code <3
I will have a look at it the next time I'm getting problems with that.
I keep this ticket opened until this is fixed by TYPO3 CMS Core :)
Updated by Oliver Hader about 2 years ago
- Status changed from New to Needs Feedback
- Assignee set to Oliver Hader
- Sprint Focus set to On Location Sprint
How did the route enhancer configuration look like? I guess /news
and /myext
are pages, thus the route
part would have been like '/details/{title}/'
, correct?
That's a usual problem with that ambiguity.
@Christoph Lehmann Thanks for sharing the code snippets. Can you describe a little bit, how it is supposed to work and how it should be used? Thanks in advance!
Updated by Oliver Hader about 2 years ago
- Has duplicate Bug #93727: Extbase Routing Enhancer with several routes doesn't work when routes use different controller added
Updated by Christoph Lehmann about 2 years ago
In the following example News and Contacts have the same route path "/{news-title}" and "/{contact-title}". ExtbaseRequiringPluginOnPage in the first routeEnhancer makes it possible.
routeEnhancers: News: type: ExtbaseRequiringPluginOnPage extension: News plugin: Pi1 routes: - routePath: '/' _controller: 'News::list' - routePath: '/{news-title}' _controller: 'News::detail' _arguments: news-title: news - 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 category-name: type: PersistedAliasMapper tableName: sys_category routeFieldName: slug Contacts: type: Extbase extension: SomeAddress plugin: ShowContact routes: - routePath: '/{contact-title}' _controller: 'Contact::show' _arguments: contact-title: contact aspects: contact-title: type: PersistedAliasMapper tableName: tx_some_domain_model_contact routeFieldName: slug
ExtbaseRequiringPluginOnPage checks if there is a news plugin on the page and depending on the result it decorates the route or not. If not, then the next route enhancer tries to decorate the route path.
So, if you have 3 different plugins having the same route path, then ExtbaseRequiringPluginOnPage needs to be used for the two beginning routeEnhancers. (Didn't tried).
routeEnhancers: News: type: ExtbaseRequiringPluginOnPage Contacts: type: ExtbaseRequiringPluginOnPage Events: type: Extbase
Using ExtbaseRequiringPluginOnPage leads to one extra SQL query per request.
Updated by Oliver Hader about 2 years ago
- Status changed from Needs Feedback to Accepted
Updated by Oliver Hader about 2 years ago
What do you think about having a new settings for corresponding enhancers? For instance
routeEnhancers: News: type: ExtbaseRequiringPluginOnPage extension: News plugin: Pi1 # use plugin name from settings requiresPluginOnPage: true # use specific plugin name, might be different to current enhancer settings, e.g. `tx_news_pi9` requiresPluginOnPage: 'news_pi9'
A further optimization would be to fetch all plugins names for the current resolved page and put those names for the plugin-check to a runtime cache.
Updated by Christoph Lehmann about 2 years ago
I like the solution with the new option.
But, without looking into the code, doesn't do
requiresPluginOnPage: 'news_pi9'
the same like using this?
requiresPluginOnPage: true plugin: Pi9
Updated by Oliver Hader about 2 years ago
For Extbase
and Plugin
enhancers this is correct, for e.g. Simple
enhancers it needs to be explicit.
But it would be fine for me to go with requiresPluginOnPage: true
, since anything seems to be an edge case.
Updated by Gerrit Code Review almost 2 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/77181
Updated by Gerrit Code Review almost 2 years ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/77181
Updated by Christoph Lehmann almost 2 years ago
Instead of using
requiresPluginOnPage: true
it's more practical to use a comma-separated list of plugins like
requiresPluginOnPage: Pi1, NewsDetail
since extensions can have multiple plugins allowing the same route.
Updated by Gerrit Code Review almost 2 years ago
Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/77181
Updated by Gerrit Code Review almost 2 years ago
Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/77181
Updated by Gerrit Code Review almost 2 years ago
Patch set 5 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/77181
Updated by Gerrit Code Review over 1 year ago
Patch set 6 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/77181
Updated by Benni Mack over 1 year ago
- Sprint Focus deleted (
On Location Sprint)