I have a very big menu that have items that are not ordered correctly by alphabet. This seems to be a problem with non English strings having special German chars. Looking into the vocabulary them-self all terms are correctly ordered. Here are a few examples for testing:

Incorrect:

Afghanistan
Albanien
...
Zypern
Ägypten
Östereich

Correct:

Afghanistan
Ägypten
Albanien
...

Comments

indytechcook’s picture

Thanks hass. I use taxonomy_get_tree to pull the list of terms. This should be respecting the correct weight. Do you have another suggestion?

hass’s picture

I do not have any weight configured myself... core sorts correctly itself with weight = 0. You may take a look how core solve the ordering... I have never taken a look how this ordering is done.

indytechcook’s picture

Taxonomy Menu and Taxonomy both use taxonomy_get_tree to pull the vocabulary and cycling through it in the order it was received from that function.

The only different appears in vocabularies that are set as 'tags' Are you using a tags vocab?

indytechcook’s picture

Status: Active » Postponed (maintainer needs more info)

Change status

hass’s picture

Sorry, what do you mean with tags? My terms have only a title and fields added with the term fields module, but this is not important here.

hass’s picture

Do you mean free tagging with "tags"? I'm not using free tagging...

indytechcook’s picture

hmm.. Ok. Can you please attach an XML export of your taxonomy and give me all of your taxonomy menu settings so I can reproduce?

You are welcome to email them to me if you don't want to post them.

hass’s picture

How should I export to XML?

indytechcook’s picture

Use this module: http://drupal.org/project/taxonomy_xml. It's also how I keep taxonomy's in sync between environments also :)

indytechcook’s picture

Status: Postponed (maintainer needs more info) » Active

The terms as saved in the correct order, the issue appears to be how the menu system is pulled. I'll add waits to the menu save function to keep the order.

indytechcook’s picture

Status: Active » Fixed
hass’s picture

Great, thx.

Status: Fixed » Closed (fixed)

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

indytechcook’s picture

Version: 6.x-2.4-beta3 » 6.x-2.x-dev
Status: Closed (fixed) » Active

I had to back out this change. I caused to many issues with updating the taxonomy. #780720: Menu weight not being set properly.

reopening this issue. There needs to be a better way. possibly updating the taxonomy weight on hook_taxonomy.

hass’s picture

Any plans about the time frame you need to get this finally fixed?

indytechcook’s picture

Well, I'm not sure of the correct approach. The original fix was just to work around the difference in ordering between the menu and taxonomy systems.

One recommendation was to create an option to "Order by Alphabet" which sets all of the weights to '0'. I'm not sure if this will work but others have had some success hard coding this.

It really bothers me that I can't just use the taxonomy term's weight as the menu weight. I use taxonomy_get_tree to pull and insert the terms as menu items in the correct order (the same function the taxonomy module uses).

Another problem is that reseting the vocab to alphabetical doesn't trigger any hooks so I have no way to reordering the menu unless I use DB triggers (which i'm not doing).

The only other option is to have taxonomy menu track the weights, but put in more resource intensive functions to check the parents, preceding terms to set reset the weight of the menu items. I'm worried about the load this will be for every term update.

I'm open to thoughts.

indytechcook’s picture

A possible fix is to place an option what sets the menu weight to 0 on initial insert. I will not hard code the weight = 0 for all occurrences. This will cause to many other bugs.

hanoii’s picture

subcribe

tomsm’s picture

A hard coded fix:

I changed line 542 of taxonomy_menu.module from

$link['weight'] = $item['weight'];

to

$link['weight'] = 0;

to have alphabetical sorting in all languages.

tomsm’s picture

Version: 6.x-2.x-dev » 6.x-2.9
MattBrigade’s picture

I have came across a way to ensure the weight of the menu items are set to 0 (to list items alphabetically) and NOT have to hack the module. The Taxonomy Menu does actually provide some hooks for other modules to alter the menu items as they are saved/updated.

You need to set up a small custom module. You could name it something along the lines of "taxonomy_menu_mods". (If you don't know how to create a custom module, you can learn how pretty quickly with this great tutorial: http://drupal.org/node/206753)

Inside the module, use the following hooks (NOTE: Replace "mymodule" with whatever yo decided to name your module):


function mymodule_taxonomy_menu_insert(&$item) {
  $item['weight'] = 0;
}
function mymodule_taxonomy_menu_update(&$item) {
  $item['weight'] = 0;
}

That's it! To force Taxonomy Menu to reset all the weights, go to your vocabulary's settings page, check-off "Select to rebuild the menu on submit" and hit "Save". All Taxonomy Menu items set/saved from there on out will be created with a weight value of "0".

Hope that helps!

tomsm’s picture

@ mattapus
Thank you for the tip!

hass’s picture

The original issue was only about non-latin characters... Above hack sounds not like a real solution.

MattBrigade’s picture

My apologies if my post isn't a real fix for this issue. There was talk is posts #17 and #19 about forcing the Taxonomy Menu item's weights to 0. They were hacking the module to achieve this which is not quite ideal. I was just pointing out a way to do the same thing through hooks instead.

dstol’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

The Drupal 6 version is no longer supported