When I've reorder taxonomy terms in my vocabulary I've got the effect in node creation page. But Menu that created with Taxonomy Menu module has not changed.
Please, is it possible after clear cache to reorder menu? Hope it will not take much resources from hosting server when will work this way.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tlito created an issue. See original summary.

akleinwaechter’s picture

I just added one line of code to make it work:
src -> Entity -> TaxonomyMenu.php

almost at the end:
// TODO: Consider implementing a forced weight based on taxonomy tree.

// Generate link.
$arguments = ['taxonomy_term' => $term_id];

$link = $base_plugin_definition;
$link += array(
'id' => $this->buildMenuPluginId($term),
'title' => $term->label(),
// Sascha: weight added
'weight' => $term->getWeight(),

'description' => $term->getDescription(),
'menu_name' => $menu_id,
'metadata' => array(
'taxonomy_menu_id' => $taxonomy_menu_id,
'taxonomy_term_id' => $term_id,
),
'route_name' => $term_url->getRouteName(),
'route_parameters' => $term_url->getRouteParameters(),
'load arguments' => $arguments,
'parent' => $menu_parent_id,
'provider' => 'taxonomy_menu',
'class' => 'Drupal\taxonomy_menu\Plugin\Menu\TaxonomyMenuMenuLink',
);

return $link;
}
}

Lukas von Blarer’s picture

Category: Task » Bug report
Priority: Normal » Major
Status: Active » Needs review
FileSize
519 bytes

This worked for me. Attaching a patch for this.

  • dstol committed 91276c5 on 8.x-3.x authored by Lukas von Blarer
    Issue #2762037 by Lukas von Blarer: Order of Menu items according to the...
dstol’s picture

Status: Needs review » Fixed

Thanks!

anou’s picture

I do not think this is a good idea to make it automatic. I just wanted to create an issue where I was about to say that when I edit a taxonomy term, my taxonomy menu gets reordered!

Sorry to tell that this should not happen. The ordering of the menu must be independent from the ordering of the taxonomy.

The option I can see is to make it optional in the edit form of a term and/or in the edit form of the vocabulary, like a checkbox asking you if you want to order the taxonomy menu to reflect the taxonomy terms order...

anou’s picture

Status: Fixed » Needs work
megadesk3000’s picture

Hi

I added a new patch. Now it is possible to configure whether the user wants to use the weight of the terms or sort alphabetically per taxonomy_menu entity.
Clear your cache after you installed patch and configure the taxonomy_menu entities to use the terms weight.

Greetings
Jan

megadesk3000’s picture

Status: Needs work » Needs review
megadesk3000’s picture

FileSize
2.37 KB
mariacha1’s picture

Status: Needs review » Reviewed & tested by the community

This works great!

Checking the box to impose the weight and doing a cache clear makes my menu items show up in the weight order.

Unchecking that box and doing a cache clear returns them to alphabetical.

gaurav.kapoor’s picture

+1 for RTBC.

CulacovPavel’s picture

Tested Worked

Selfirian’s picture

It does work but somehow whenever I save something else, the menu reverts to everything on the same line. It seems the weight gets respected but not the parent/child information.

Lukas von Blarer’s picture

Could we get this committed?

eloivaque’s picture

#8 patch works for me.
#10 doesn't work.

Lukas von Blarer’s picture

#10 is an interdiff, not a patch.

dstol’s picture

Status: Reviewed & tested by the community » Fixed

@Lukas, of course!

Thanks for the contributions!

  • dstol committed aa6abc4 on 8.x-3.x authored by megadesk3000
    Issue #2762037 by megadesk3000, Lukas von Blarer: Order of Menu items...

Status: Fixed » Closed (fixed)

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