Pending

User tests: Successful: Unsuccessful:

avatar Hackwar
Hackwar
26 Jul 2026
  • I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.

Summary of Changes

The current advanced component router with the router rules depends on methods in the router with magic names like get<ViewName>Segment() and get<ViewName>Id(), which can not be parsed by static code analysers or IDEs. This makes it error prone and is also difficult for developers to understand. At the same time, this means that we are duplicating a lot of code to handle categories in all routers the same way and we need empty methods for constructs like category and categories.

This PR introduces a new configuration in the RouterViewConfiguration class where you can explicitely set these callbacks instead of relying on the magic methods. This means not only that you could use methods outside of the router to build or parse the segment, but also that third party code could override the behavior without changing the router itself. Also, this introduces the CategoryCallbackTrait, which takes the category behavior from the different core routers and puts them into a reusable trait. The whole change is also entirely backwards compatible, since it still falls back to the magic methods if no callback is registered.

To use the new method, simply extend the configuration of your view with ->setBuildCallback([$this, 'yourBuildCallbackMethod']) and ->setParseCallback([$this, 'yourParseCallbackMethod']). If you want to use the CategoryCallbackTrait, use it in your components router, set the category factory in the constructor, add ->setParseCallback([$this, 'getCategoryId'])->setBuildCallback([$this, 'getCategorySegment']); to your category and categories view and remove your custom methods in your router to use the ones from the trait instead.

Open issues

  1. The trait currently still depends on the noIDs attribute, which exists in the core content routers. Third party extensions might not support this at all and not have that attribute. Which way should we go here?
  2. Should the old magic methods be deprecated? How do we deprecate just this execution branch of the affected methods?

Testing Instructions

See that your URLs still remain the same and work as before. Notice that the URLs and routing of com_contact and com_newsfeeds still work fine, even though they haven't been touched yet.

Link to documentations

Please select:

  • Documentation link for guide.joomla.org:

  • No documentation changes for guide.joomla.org needed

  • Pull Request link for manual.joomla.org: joomla/Manual#716

  • No documentation changes for manual.joomla.org needed

avatar Hackwar Hackwar - open - 26 Jul 2026
avatar Hackwar Hackwar - change - 26 Jul 2026
Status New ⇒ Pending
avatar joomla-cms-bot joomla-cms-bot - change - 26 Jul 2026
Category ⇒ Front End com_content Libraries
avatar Hackwar Hackwar - change - 15 Oct 2026
The description was changed
avatar Hackwar Hackwar - edited - 15 Oct 2026
avatar TLWebdesign
TLWebdesign - comment - 15 Oct 2026

Hi,
Tested on 6.2-dev (6.2.1-dev nightly) with the PR's files applied. Menu-item URLs for categories, articles, contacts and news feeds are unchanged, as are "Remove IDs from URLs" on/off and the redirects for wrong aliases. But articles without a menu item of their own break: their links, /index.php/component/content/article/?catid=N, answer 404 (the base serves them).
Cause: in NomenuRules::parse() the new parseCallback branch only handles nestable views; the magic-method branch below it also has an else for non-nestable views (article), which the new branch lacks, so the article id is never parsed and the leftover segment gives a

avatar TLWebdesign
TLWebdesign - comment - 15 Oct 2026

Hi,
Tested on 6.2-dev (6.2.1-dev nightly) with the PR's files applied. Menu-item URLs for categories, articles, contacts and news feeds are unchanged, as are "Remove IDs from URLs" on/off and the redirects for wrong aliases. But articles without a menu item of their own break: their links, /index.php/component/content/article/?catid=N, answer 404 (the base serves them).
Cause: in NomenuRules::parse() the new parseCallback branch only handles nestable views; the magic-method branch below it also has an else for non-nestable views (article), which the new branch lacks, so the article id is never parsed and the leftover segment gives a 404.

avatar HLeithner
HLeithner - comment - 5 Nov 2026

This pull request has been automatically rebased to 6.3-dev. Joomla! 6.2 is now in feature freeze.

avatar HLeithner HLeithner - change - 11 Nov 2026
Title
…
[6.2] Routing: Explicitely configure callbacks and introduce trait
[6.3] Routing: Explicitely configure callbacks and introduce trait
avatar HLeithner HLeithner - edited - 11 Nov 2026

Add a Comment

Login with GitHub to post a comment