#95766Routing across extensions
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.
Reviews 1
Related issues 1
History 1521
-
Christoph Lehmann commented <span data-processor="relativetime" data-value="2021-10-26T16:48:03+00:00" > 10/26/21, 16:48 </span>
-
Sven Burkert commented <span data-processor="relativetime" data-value="2021-10-28T16:49:28+00:00" > 10/28/21, 16:49 </span>
Yes, but this isn’t a solution for pages where editors can use the plugin on every page they want to.
-
Christoph Lehmann commented <span data-processor="relativetime" data-value="2022-04-10T13:49:55+00:00" > 04/10/22, 13:49 </span>
Maybe this helps you: https://gist.github.com/christophlehmann/48b6f5e752f3d2cf4c2c077f5ac5b9b1
-
Sven Burkert commented <span data-processor="relativetime" data-value="2022-06-03T15:31:00+00:00" > 06/03/22, 15:31 </span>
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 :)
-
Oliver Hader commented and changed status
NewNeeds Feedback assigned to Oliver Hader Sprint Focus On Location Sprint <span data-processor="relativetime" data-value="2022-11-03T12:23:44+00:00" > 11/03/22, 12:23 </span>How did the route enhancer configuration look like? I guess
/newsand/myextare pages, thus theroutepart would have been like'/details/{title}/', correct?That’s a usual problem with that ambiguity.
@christophl 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!
-
Oliver Hader changed Duplicated by #93727 <span data-processor="relativetime" data-value="2022-11-03T15:03:27+00:00" > 11/03/22, 15:03 </span>
-
Christoph Lehmann commented <span data-processor="relativetime" data-value="2022-11-04T10:27:09+00:00" > 11/04/22, 10:27 </span>
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: slugExtbaseRequiringPluginOnPage 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: ExtbaseUsing ExtbaseRequiringPluginOnPage leads to one extra SQL query per request.
-
Oliver Hader changed status
Needs FeedbackAccepted <span data-processor="relativetime" data-value="2022-11-12T07:54:02+00:00" > 11/12/22, 07:54 </span> -
Oliver Hader commented <span data-processor="relativetime" data-value="2022-11-12T07:58:40+00:00" > 11/12/22, 07:58 </span>
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.
-
Christoph Lehmann commented <span data-processor="relativetime" data-value="2022-11-16T08:50:50+00:00" > 11/16/22, 08:50 </span>
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
-
Oliver Hader commented <span data-processor="relativetime" data-value="2022-11-16T10:56:06+00:00" > 11/16/22, 10:56 </span>
For
ExtbaseandPluginenhancers this is correct, for e.g.Simpleenhancers it needs to be explicit.
But it would be fine for me to go withrequiresPluginOnPage: true, since anything seems to be an edge case. -
Gerrit Code Review pushed patch set 1 for main to change 77181 status
AcceptedUnder Review <span data-processor="relativetime" data-value="2022-12-17T09:35:43+00:00" > 12/17/22, 09:35 </span> -
Gerrit Code Review pushed patch set 2 for main to change 77181 <span data-processor="relativetime" data-value="2022-12-17T10:08:47+00:00" > 12/17/22, 10:08 </span>
-
Christoph Lehmann commented <span data-processor="relativetime" data-value="2022-12-17T10:13:38+00:00" > 12/17/22, 10:13 </span>
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.
-
Gerrit Code Review pushed patch set 3 for main to change 77181 <span data-processor="relativetime" data-value="2022-12-17T10:16:41+00:00" > 12/17/22, 10:16 </span>
-
Gerrit Code Review pushed patch set 4 for main to change 77181 <span data-processor="relativetime" data-value="2022-12-17T10:26:08+00:00" > 12/17/22, 10:26 </span>
-
Gerrit Code Review pushed patch set 5 for main to change 77181 <span data-processor="relativetime" data-value="2022-12-17T10:40:05+00:00" > 12/17/22, 10:40 </span>
-
Gerrit Code Review pushed patch set 6 for main to change 77181 <span data-processor="relativetime" data-value="2023-03-25T21:59:25+00:00" > 03/25/23, 21:59 </span>
-
Benni Mack changed Sprint Focus
On Location Sprint<span data-processor="relativetime" data-value="2023-08-02T13:04:57+00:00" > 08/02/23, 13:04 </span> -
Georg Ringer changed Related to #109263 <span data-processor="relativetime" data-value="2026-09-17T15:35:18+00:00" > 09/17/26, 15:35 </span>
-
Georg Ringer commented and changed status
Under ReviewClosed <span data-processor="relativetime" data-value="2026-09-17T15:35:54+00:00" > 09/17/26, 15:35 </span>I am closing this issue as this has been solved with #109263, see https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/14.2/Feature-109263-ExpressionLanguageSupportForLimitToPagesInRouteEnhancers.html for the rst
Does it work for you with limitToPages ?
(https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Routing/AdvancedRoutingConfiguration.html#simple-enhancer)