This has been reported a few times since the release of j4 and I think I have finally got to the bottom of it. Sadly I dont have the fix but I hope there is enough information here for someone to be able to fix the missing piece
To see the problem in action (any version of Joomla) go to the content categories menu and click on one of the counters to open a filtered view of the articles.
This will correctly open the article view with the selected filter
The problem however is that we have now lost the active menu item in the menu sidebar
It should be displayed like this
The reason for this is that the url generated in the category view is structured
administrator/index.php?option=com_content&filter[category_id]=2&filter[published]=1&filter[level]=1
Note that there is no view=articles
The link worked because articles is the default view for com_content but the active menu is not set because that relies on the view
You can verify that the acticve menu is correctly selected if you manually set the url to be
administrator/index.php?option=com_content&view=articles&filter[category_id]=2&filter[published]=1&filter[level]=1
If we look at the code in com_categories for generating the link
there is code for adding the view but $section is always empty
This block of code was added by @bembelimen way back in 3.5.1#9580
I think that was for something else whcih we see with fields where the urls has content=com_content.article but the important thing is that this bug is fixed by adding the correct view to the url
The important thing is that this is not something that can be fixed in the menu or the js as the problem is the missing view in the url from the category component
5.4
No response
No response
No response
also see #34067
| Labels |
Added:
No Code Attached Yet
bug
|
||
Not sure if I understood it correctly, but missing hidden menus has a very easy reason: https://github.com/joomla/joomla-cms/blob/5.4-dev/build/media_source/mod_menu/js/admin-menu.es6.js#L98
The menus are wrongly compared. Correctly they should be compared parameter-wise, so if option, view and layout (not sure about that) are the same. Currently the menu are compared just by string. So changing the order of a menu or adding any extra parameter makes the element not active any more. Additionally if menu and link has same view prefix, they get highlighted as active.
index.php?option=com_example&view=foo is same as index.php?option=com_example&view=foobar because one is the "prefix" of the other.
Solution: https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/get + correct compare.
@bembelimen the problem is that in this case there is no view in the url
Correct extension would be com_content.article I guess. There is no real fix, only a band aid fix by changing the lines you marked. Better would be to have always a section. Still the whole menu active thing is broken in some way.
@LadySolveig has fixed most of the menu active stuff but this is a different beast
This issue in com_categories and I found why it happens.
When the extension is just com_content (without a dot), the code in default.php doesn't find the section, so it returns a null view. This is exactly what Brian mentioned and I added a fallback to deduce the section from the component name (with a special check for com_content to use articles
I prepared something that works similar to the frontend. I think that could happen in 7 at the earliest, if at all. Since it includes B/C breaks.
@LadySolveig interesting but this PR from @Reda-Muhamed is fully b/c as far as i can see
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
@LadySolveig i hope this information helps