Adding a functionality to allow hiding unpublished/disabled taxonomy terms from menus would be great.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

makbay created an issue. See original summary.

makbay’s picture

Status: Active » Needs review
marios anagnostopoulos’s picture

StatusFileSize
new1.04 KB

Attaching a patch for the existing MR.

I have tested this and it works as expected. Needs CR for changes to appear, but I guess that is the way pretty much everything works with menu items.

However, I would prefer if the whole operation would take place during the link definition creation/update in generateTaxonomyMenuEntries and updateTaxonomyMenuEntries. The caveat there is that I don't see a good way to show/hide per language.

IDK is there any issue about having different enabled status per language for menu links?

emberhood’s picture

StatusFileSize
new1.03 KB

Attaching a patch adding respect of parent enable check of term link.

This is considered needed in case of conflict with work done in other places like this one: https://www.drupal.org/files/issues/2023-10-13/taxonomy_menu-hide_empty_...

sandeep_k’s picture

StatusFileSize
new111.58 KB
new45.37 KB

Hi, I've Tested MR- MR !9 mergeable on Drupal version- 10.1.9-dev. The MR was applied successfully and looks good to me.

Testing Steps:

  • Set up Drupal 10.1.9.
  • Download/Enable the Taxonomy Menu module.
  • Create Taxonomy Menu> Create new terms> Published & unpublished. You can see unpublished terms are also showing in the menu, Added before results
  • Download the shared patch & apply.
  • Go back to the site home & Reverify the menu.

Testing Results:
After applying the patch, the Unpublished terms are not showing now.

g-brodiei’s picture

StatusFileSize
new805.32 KB
new628.68 KB
new1.06 KB

Hi, we've met the same issue on a use case to render a taxonomy menu by linkset feature.

We're using Drupal 10.2.5, taxonomy_menu 3.6

The test in merge request does not update the menu item shown in linkset endpoint, please see the gif below where I'd unpublished the term.

Steps with old patch:

  1. Unpublished term
  2. Refresh to check menu item disabled, yes
  3. Refresh endpoint of linkset menu to have menu item disappear, still exists

I've figured out another fix that successfully updates the menu item's "enabled" property while also affects linkset endpoint.

Steps with new patch:

  1. Unpublished term
  2. Refresh to check menu item disabled, yes
  3. Refresh endpoint of linkset menu to have menu item disappear, the unpublished menu item disappears as well
damienmckenna’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests
Parent issue: » #3343677: Plan for Taxonomy Menu 8.x-3.7

We definitely want to get this in the next release.

Can someone please update the MR to include the latest changes in the 8.x-3.x branch?

Also, this needs test coverage to make sure the change isn't accidentally broken later on.

Thank you.

dlevchik made their first commit to this issue’s fork.

dlevchik’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

MR updated: Added most recent commits from 8.x-3.x, created test case for unpublished taxonomy term

damienmckenna’s picture

Status: Needs review » Fixed

Great work, thank you!

Committed.

damienmckenna’s picture

Category: Feature request » Bug report
damienmckenna’s picture

damienmckenna’s picture

damienmckenna’s picture

Issue tags: +Security improvements

FYI after discussing it with the security team it was decided that this fit under PSA-2023-07-12. In short, while there is a security aspect to this, it is such an unlikely scenario to happen that it was deemed fixable in public. As such, there won't be an advisory for this fix.

szeidler’s picture

The change has caused a big regression for us on translatable vocabularies. Now every taxonomy menu item is shown twice.

Sorry, it seems to have been a problem with our particular setup, that just became visible now with the update.

damienmckenna’s picture

Thank you for the clarification, szediler.

karlshea’s picture

Not all of the patch changes made it in, so it's not possible to get or alter the enabled item. I'll open a new issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

marios anagnostopoulos’s picture

The parent support introduced in #5 seems to be missing.
Is there any specific reason this was omitted?

marios anagnostopoulos’s picture

Attaching a patch to the current version with the change mentioned in #5 about respecting parent Plugin enabled status

marios anagnostopoulos’s picture

StatusFileSize
new834 bytes

EDIT: IDK if I should reopen the issue or create a followup or wait for feedback

batigolix’s picture

@marios anagnostopoulos : this issue is already closed, so yes: please make a new issue for this.