My source language is English and the terms are sorted alphabetical.
But my translated menus (Dutch and French) are not. Is it possible to include an option so that the terms are sorted alphabetical for every language.
I use a vocab with localized terms.
This issue is already discussed here: http://drupal.org/node/316632
and a possible fix has been introduced by klavs:
The sorting issue is a seperate issue - and should have a seperate issue created for it.
I found that the menu system only sorts alphabeticly - if items have a weight of 0 (just by googleing - so no guarantees :)
This module pr. default - inserts items in the order they have in the taxonomy - and this stays - even when translated.
If you want it to sort alphabeticly - you could do this:
In function _taxonomy_menu_save:
Line ~497 - make sure it looks like this instead (comment out 3 lines and insert the weight = 0;)
//$weight = variable_get('taxonomy_menu_weight', 0);
//$weight++;
//variable_set('taxonomy_menu_weight', $weight);
$weight = 0;
This should IMHO be setup as an option in the taxonomy_menu with a name like "sort alphabeticly - instead of according to taxonomy sort" - and then it could just check for that in the mentioned function.
I have tried this, but I cannot find the lines I need to comment out.
I use the latest dev.
Comments
Comment #1
indytechcook commented@tomsm, that code was removed in the latest dev. It was causing all sorts of other issues.
Comment #2
tomsm commentedOk, I thought so. Is there another way to fix this sorting issue?
Comment #3
klavs commentedsame way - when taxonomy_menu adds the items to the menu system - it must give a weight Find wheere it does this, and ensure it gives it a weight of 0, instead of 50 (which is what it gave in the version I'm running).
Comment #4
indytechcook commented@klavs, taxonomy_menu uses the term weight to set the menu weight. setting all of them to 0 would override any manual changes.
You had the problem before because of some code I put in to try and work around a sorting issue in the menu system.
The problem is that the taxonomy UI and the menu block do not order in the same way. That's the root problem and everything else that I've (or anyone else) has done is just a way to work around that problem.
Check the latest dev, you should no longer need to set the weight to 0.
Comment #5
tomsm commentedWhen the weight for each term is set to 0, are the translated menus then also ordered alphabetically?
Comment #6
tomsm commentedThanks to the information supplied in previous posts, I have found a way:
at line 522 I changed:
'weight' => $item['weight'],to
'weight' => 0,Now all terms are sorted alphabetically in all languages.
Maybe an option can be added to the user interface that enables/disables this alphabetical sorting behavior?
Comment #7
tomsm commentedI just installed the latest dev. (July 12, 2010)
I changed line 542 from
$link['weight'] = $item['weight'];to
$link['weight'] = 0;to have alphabetical sorting in all languages.
Is it possible to add a feature allowing to sort the menu items alphabetically in all languages, please?
Comment #8
indytechcook commentedRelating this to orig issue. #641036: Items not correctly orderd by alphabet
Comment #9
tomsm commented#7 also works for 6.x-2.9
Comment #10
MattBrigade commentedI have discovered 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):
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!