Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#10 | interdiff-2762037-3-8.txt | 2.37 KB | megadesk3000 |
#8 | order_of_menu_items-2762037-8.patch | 2.53 KB | megadesk3000 |
| |||
#3 | 2762037-weight-3.diff | 519 bytes | Lukas von Blarer |
|
Comments
Comment #2
akleinwaechter CreditAttribution: akleinwaechter commentedI 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;
}
}
Comment #3
Lukas von BlarerThis worked for me. Attaching a patch for this.
Comment #5
dstolThanks!
Comment #6
anouI 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...
Comment #7
anouComment #8
megadesk3000 CreditAttribution: megadesk3000 at Unic commentedHi
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
Comment #9
megadesk3000 CreditAttribution: megadesk3000 at Unic commentedComment #10
megadesk3000 CreditAttribution: megadesk3000 at Unic commentedComment #11
mariacha1 CreditAttribution: mariacha1 at ThinkShout commentedThis 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.
Comment #12
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs commented+1 for RTBC.
Comment #13
CulacovPavel CreditAttribution: CulacovPavel commentedTested Worked
Comment #14
Selfirian CreditAttribution: Selfirian commentedIt 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.
Comment #15
Lukas von BlarerCould we get this committed?
Comment #16
eloivaque#8 patch works for me.
#10 doesn't work.
Comment #17
Lukas von Blarer#10 is an interdiff, not a patch.
Comment #18
dstol@Lukas, of course!
Thanks for the contributions!