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:

  • 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

Add a Comment

Login with GitHub to post a comment