[4.0] Hide disabled components in mod_submenu#32555
[4.0] Hide disabled components in mod_submenu#32555wilsonge merged 5 commits intojoomla:4.0-devfrom alikon:patch-81
Conversation
|
this actually looks much better than #32539 |
|
|
||
| foreach ($children as $item) | ||
| { | ||
| if (!ComponentHelper::isEnabled($item->element)) |
There was a problem hiding this comment.
you also need to check the $item type to be a component, because there may be a spacers or something else.
if I right remember
There was a problem hiding this comment.
I thought about if ($item->type === 'component' ...
but I do not remember how it exactly there, need to check, later
|
|
||
| foreach ($children as $item) | ||
| { | ||
| if (!empty($item->element) && (!ComponentHelper::isEnabled($item->element))) |
There was a problem hiding this comment.
Could you change the code to
if ($item->element && !ComponentHelper::isEnabled($item->element))It is a bit easier to read, same with the code in mod_menu https://github.com/joomla/joomla-cms/blob/4.0-dev/administrator/modules/mod_menu/src/Menu/CssMenu.php#L313
There was a problem hiding this comment.
No, it is not done yet. You still have unnecessary ( and ). Please change it exactly to:
if ($item->element && !ComponentHelper::isEnabled($item->element))There was a problem hiding this comment.
There was a problem hiding this comment.
@alikon You still have unnecessary bracket ( and ) in the code as I said. The code should be
if ($item->element && !ComponentHelper::isEnabled($item->element))The current code is:
if ($item->element && (!ComponentHelper::isEnabled($item->element)))There was a problem hiding this comment.
ah my bad didn't look at bracket
|
btw, we have similar in mod_menu also 😉 joomla-cms/administrator/modules/mod_menu/src/Menu/CssMenu.php Lines 312 to 317 in fa6cc5d so all should be good |
|
@alikon I was so free to change the title for you so we later have a better commit message when merging the PR. |
|
I have tested this item 🔴 unsuccessfully on abd61d4 After applying patch, without turning off any components, some items disappeared: It seems these three Language related items are not following the same configuration as the other items in the list. As Language component is a protected one, it can't be disabled, but I'm not sure why it's not otherwise appearing. Aside from the Language items, the PR works as expected when I turned off either CSP or Redirects as two items available to disable in that dashboard module. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32555. |
|
@particthistle I think the error here is not related to this PR. I don't understand how menu presets work, but someone familiar with that concept should check https://github.com/joomla/joomla-cms/blob/4.0-dev/administrator/components/com_menus/presets/system.xml#L127-L149 to see why element="com_language", not element="com_languages" (I think it is typos). One that issue is fixed, the error you reported here won't happen. |
@joomdonation @particthistle Who wants to make a PR? |
not com_language
|
better to do it in this pr imho |
|
I have tested this item ✅ successfully on 9511451 Glad it was something easy for you to resolve @alikon as I wouldn't have known where to start to fix that up. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32555. |
|
I have tested this item ✅ successfully on 9511451 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32555. |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32555. |
|
LGTM. Nice work everyone! |
Pull Request for Issue #32456.
Summary of Changes
don't show items from disabled component in mod_submenu
Testing Instructions
see #32456.
Actual result BEFORE applying this Pull Request
see #32456.
Expected result AFTER applying this Pull Request
no items from disabled components are shown
alterrnative to #32539
let's see how many 👎 i got 🤣