bug PR-5.4-dev Pending

User tests: Successful: Unsuccessful:

avatar Reda-Muhamed
Reda-Muhamed
10 Mar 2026

Summary of Changes

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.

Testing Instructions

  1. Log in to the Joomla Administrator backend.
  2. Navigate to Content -> Categories (or any other component using categories like Contacts or Banners).
  3. Ensure there is at least one category with items in it.
  4. Click on the item counter badge.
  5. Observe the generated URL in your browser and the state of the left sidebar menu.

Actual result BEFORE applying this Pull Request

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.

Expected result AFTER applying this Pull Request

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.

Link to documentations

No documentation changes required.

Fixes #47344

avatar Reda-Muhamed Reda-Muhamed - open - 10 Mar 2026
avatar Reda-Muhamed Reda-Muhamed - change - 10 Mar 2026
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 10 Mar 2026
Category Administration com_categories
avatar brianteeman brianteeman - comment - 10 Mar 2026
avatar brianteeman brianteeman - test_item - 10 Mar 2026 - Tested successfully
avatar brianteeman
brianteeman - comment - 10 Mar 2026

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.

avatar richard67
richard67 - comment - 10 Mar 2026

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.

avatar richard67 richard67 - change - 10 Mar 2026
Title
Fix missing view parameter in category item links to keep menu active
[5.4] Fix missing view parameter in category item links to keep menu active
avatar richard67 richard67 - edited - 10 Mar 2026
avatar HLeithner HLeithner - close - 10 Mar 2026
avatar HLeithner
HLeithner - comment - 10 Mar 2026

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.

avatar HLeithner HLeithner - change - 10 Mar 2026
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
avatar brianteeman
brianteeman - comment - 10 Mar 2026

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)

avatar LadySolveig
LadySolveig - comment - 10 Mar 2026
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?

avatar Reda-Muhamed
Reda-Muhamed - comment - 10 Mar 2026

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

avatar richard67 richard67 - change - 10 Mar 2026
Status Closed New
Closed_Date 2026-03-10 16:44:13
Closed_By HLeithner
avatar richard67 richard67 - change - 10 Mar 2026
Status New Pending
avatar richard67 richard67 - reopen - 10 Mar 2026
avatar richard67
richard67 - comment - 10 Mar 2026

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.

avatar charvimehradu
charvimehradu - comment - 10 Mar 2026

@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.

avatar Reda-Muhamed Reda-Muhamed - change - 10 Mar 2026
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2026-03-10 20:52:01
Closed_By Reda-Muhamed
Labels Added: bug
avatar Reda-Muhamed
Reda-Muhamed - comment - 10 Mar 2026

Thank you @richard67 for the suggestion. I will close this PR and open a new one with the code

avatar Reda-Muhamed Reda-Muhamed - close - 10 Mar 2026
avatar LadySolveig
LadySolveig - comment - 10 Mar 2026

@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.

avatar Reda-Muhamed
Reda-Muhamed - comment - 10 Mar 2026

@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

Add a Comment

Login with GitHub to post a comment