In many cases, you want to only select part of a taxonomy. This enables you to select a base term; in which case menu items will only be generated for it's childrens.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

NickWilde created an issue. See original summary.

NickDickinsonWilde’s picture

Status: Active » Needs review
FileSize
8.28 KB

Patch.

sascher’s picture

I applied this patch to version 3.3 of taxonomy menu module and Drupal core 8.3.1

I chose the first term that is a parent and got this error in the db log upon save

Drupal\Component\Plugin\Exception\PluginException: The menu link ID taxonomy_menu.menu_link:taxonomy_menu.menu_link.test_tags.5 already exists as a plugin definition in Drupal\Core\Menu\MenuLinkManager->addDefinition() (line 350 of /Users/stanleyascher/Sites/taxonomy_menu_hack/core/lib/Drupal/Core/Menu/MenuLinkManager.php).

dani3lr0se’s picture

@NickWilde would you be able to give me some steps to properly test this? I have the module installed and patched but it seems really glitchy or I'm just not configuring it right. It seems like every single configuration change I make produces a different unintended outcome. Once in a while it seems like it works, but I'm not really sure I guess. I just want to make sure I'm testing it correctly. For example: I created a vocab called "Hockey Cards" with 4 terms: "Sidney Crosby", "Alex Ovechkin", "Connor McDavid" and "Auston Matthews". I then added a few more terms and then nested them under "Sidney Crosby" > "2018", "2017", "2016", etc..

When I attempt to create a taxonomy menu with Sidney Crosby as the base term and parent menu link it ends up displaying all of the terms in the main navigation. When I set the term as the parent menu link it doesn't change and when I try to clear cache thinking that might help, I get a WSOD with the error "This website encountered an error. Please try again later".

So either I'm not doing something correctly (which might be the case) or maybe something isn't working as intended?

Thanks so much for your help and work on this. :)

dstol’s picture

Status: Needs review » Needs work

Thanks for testing this daniel_rose. If you've got the patch applied, which I'm having a hard time against HEAD of 8.x-3.x, can you re-roll it?

Either way, this seems like it's needs work.

rbosscher’s picture

Status: Needs work » Needs review
FileSize
8.31 KB

I've manually applied the patch to the latest dev. It have it working, but i think it needs a little bit more love.
Especially this part, I think, is verry ugly, but I needed to do that, and I was lost on inspiration on a better solution.

   /**
    * AJAX callback; Builds the description field selector.
    */
   public static function ajaxReplaceDescriptionFieldForm(array &$form, FormStateInterface $form_state) {
+    $form = $this->updateTerms($form, $form_state);    
     return $form['description_container'];
   }
rbosscher’s picture

Status: Needs review » Needs work

Settings this to needs work instead of needs review. The patch only works until you clear the cache, after that it messes up the menu structure.

DamienMcKenna’s picture

Issue tags: +Needs tests

We need test coverage for this too, just to make sure it continues to work as expected.