User tests: Successful: Unsuccessful:
When clicking on the item counters (Published, Unpublished, Trashed, Archived) in the Category Manager (com_categories), the generated URL lacks the view parameter if the $extension variable does not contain a dot (e.g., com_content). Because the view is missing from the URL, the JavaScript menu adapter fails to match it, causing the active menu item in the sidebar (e.g., "Articles") to lose its highlighted state.
What was changed to make it work:
In administrator/components/com_categories/tmpl/categories/default.php, the logic previously set $section = null if no dot was found in the extension name. I modified this to include a smart fallback: if no dot is present, the code strips com_ from the component name to deduce the section, applies a specific override for com_content (to use article), and then safely passes it to the Inflector to be pluralized. This ensures the correct view is always appended to the URL.
The generated URL is missing the view parameter:
administrator/index.php?option=com_content&filter[category_id]=8&filter[published]=1&filter[level]=1
Because the view is missing, the sidebar menu loses its active/highlighted state.
The generated URL correctly includes the deduced view parameter:
administrator/index.php?option=com_content&view=articles&filter[category_id]=8&filter[published]=1&filter[level]=1
The left sidebar menu (e.g., "Articles") successfully remains active and highlighted.
No documentation changes required.
Fixes #47344
| Status | New | ⇒ | Pending |
| Category | ⇒ | Administration com_categories |
please confirm that this PR is made in accordance with our AI policy https://developer.joomla.org/generative-ai-policy.html
@Reda-Muhamed Please do so. Otherwise this PR will be closed.
| Title |
|
||||||
The code is wrong and only a band aid, I would not merge this. Beside that you violated the AI policy. I'm closing this PR. If you violate again you get banned.
| Status | Pending | ⇒ | Closed |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2026-03-10 16:44:13 |
| Closed_By | ⇒ | HLeithner | |
| Labels |
Added:
PR-5.4-dev
|
||
Please explain what is wrong with the code. I tested everywhere that is impacted and there were no breaks to existing uses of sections (eg fields) and everything that didn't work correctly before now works (eg categories).
(And I would have allowed more than 20 minutes before closing and threatening)
if (count($parts) > 1) {
$section = $parts[1];
} else {
$section = str_replace('com_', '', $component);
}
$inflector = Inflector::getInstance();
if (!$inflector->isPlural($section)) {
$section = $inflector->toPlural($section);
}
$viewDir = JPATH_ADMINISTRATOR . '/components/' . $component . '/src/View/' . ucfirst($section);
if (!is_dir($viewDir)) {
$section = null;
try {
$extensionObject = Factory::getApplication()->bootComponent($component);
$extensionNamespaceParts = explode('\\', (new \ReflectionClass($extensionObject))->getNamespaceName());
array_pop($extensionNamespaceParts);
$displayControllerClass = implode('\\', $extensionNamespaceParts) . '\\Controller\\DisplayController';
if (class_exists($displayControllerClass)) {
$controllerDefaultProperties = (new \ReflectionClass($displayControllerClass))->getDefaultProperties();
$section = $controllerDefaultProperties['default_view'] ?? null;
}
} catch (\Exception $e) {
// Component could not be booted; leave $section as null
}
}
Wanted to make this suggestion here, but now it is cloesd. If like me to make a PR please ping me @HLeithner
Not sure if this would be the right way?
I want to clarify that I used the AI only to write the PR description and format my text, did not use AI to write the code. I read the issue, understood the problem, wrote the code myself, and tested it on my local computer
| Status | Closed | ⇒ | New |
| Closed_Date | 2026-03-10 16:44:13 | ⇒ | |
| Closed_By | HLeithner | ⇒ |
| Status | New | ⇒ | Pending |
I want to clarify that I used the AI only to write the PR description and format my text, did not use AI to write the code. I read the issue, understood the problem, wrote the code myself, and tested it on my local computer
@Reda-Muhamed Ok, accepted.
However, this PR is not really a good solution.
It fixes the issue for the core com_content component.
But com_categories shall also work for 3rd party components.
Doing a $section = str_replace('com_', '', $component); would replace the com_ also when it appears in the middle of the string, so if someone names their component com_telecom_blabla they would have a problem.
@LadySolveig suggested a solution which looks a bit complicated at a first glance but would be safer, as it tries to get the view name from the extension's controller.
I will re-open your PR now so you can improve it, but maybe it would be easier just to make a new one. If you make a new one, please close this one here again so we don't have duplicates.
Thanks for your understanding.
@Reda-Muhamed thank you for your contribution. Please try the suggestion posted by @LadySolveig. Also, kindly ensure that the PR template is followed and that the AI confirmation checkbox remains in place. Thanks.
| Status | Pending | ⇒ | Closed |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2026-03-10 20:52:01 |
| Closed_By | ⇒ | Reda-Muhamed | |
| Labels |
Added:
bug
|
||
Thank you @richard67 for the suggestion. I will close this PR and open a new one with the code
@Reda-Muhamed
In the end, however, my suggestion is actually unsuitable for a view and should, if anything, take place in a display controller.
Your first fix and also my suggestion obscures the underlying problem and opens up a new one. What about views that do not have a plural ‘s’ in the plural? They no longer work with this either.
So it makes sense to think about this a little longer. This is purely a band-aid solution and not a reasonable fix, which everyone should be aware of.
Thank you for addressing the issue and for your contribution.
@Reda-Muhamed In the end, however, my suggestion is actually unsuitable for a view and should, if anything, take place in a display controller. Your first fix and also my suggestion obscures the underlying problem and opens up a new one. What about views that do not have a plural ‘s’ in the plural? They no longer Arbeit with this either. So it makes sense to think about this a little longer. This is purely a band-aid solution and not a reasonable fix, which everyone should be aware of. Thank you for addressing the issue and for your contribution.
I agree with you about handling the controller logic inside the view violate the MVC and the irregular plurals edge case proves this needs a proper architectural fix, I have closed the PR, thanks for the explaination
I have tested this item ✅ successfully on 366e43a
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/47359.