Hello,
I hope I am posting this in the right place and in the proper way. I have read through the various issues similar to this but I have not found a solution to my problem.
Here is my issue :
What i want to achieve :
- an exposed filter with translated taxonomy terms that are ordered in the displayed language.
- be able to translate the taxonomy term from taxonomy term issue and not from string translation
What i've got :
- an exposed filter with terms translated in the Translate interface section.
- the order of elements in the exposed filter is in the alphabetical order of the elements in the original language.
The activated modules I am using :
- Views 7.x-3.7
- Entity Translation
- Internationalization 7.x-1.11
- Multilingual content 7.x-1.11
- String translation 7.x-1.11
- Taxonomy translation 7.x-1.11
- Translation sets 7.x-1.11
- Variable translation 7.x-1.11
- Views translation
Detailed description of my problem :
There is a Content Type DOCUMENTS set to :
- Multilingual support : Enabled, with field translation
- Extended language support Normal - All enabled languages will be allowed.
The content type has a Term reference entitled CLASSIFICATION which is a Autocomplete term widget (tagging) type.
The Term reference refers to a taxonomy called DOCUMENT CLASSIFICATION which is set to
Localize. Terms are common for all languages, but their name and description may be localized.
When I look edit each item of the DOCUMENT CLASSIFICATION taxonomy I have a translate tab. I can also go into /admin/config/regional/translate to translate the term string.
Now I have a view that lists all the nodes of type DOCUMENTS and an exposed filter to filter according to DOCUMENT CLASSIFICATION.
This exposed filter works fine in original language FRENCH
However in ENGLISH (i.e. when user has selected ENGLISH for navigating) the exposed filter has the translated terms but in the alphabetical order of the original terms in FRENCH.
I would like to achieve one of two things :
- Use the translated content for the taxonomy list item as opposed to the translated string to populate the exposed filter.
- Have the translated strings in the alphabetical order of the display language.
Any help would be much appreciated
Comments
Comment #1
wishiwas CreditAttribution: wishiwas commentedI think that I have come up with a working solution, although I'm not 100% clear as to the explanation :
Comment #2
wishiwas CreditAttribution: wishiwas commentedComment #3
A.Kotov CreditAttribution: A.Kotov commentedWishiwas, thank you for pointing to the function from Derek DeRaps
It works but only with 1 level taxonomy vocabulary.
Any idea how to improve it?
Comment #4
mas0h CreditAttribution: mas0h commentedThanks for the code from this http://drupal.stackexchange.com/questions/23233/how-can-i-sort-options-i...
But how about sorting in node add/edit form?
Thanks
Comment #5
morybel CreditAttribution: morybel commentedHi,
THanks to the function from Derek DeRaps I was also able to get this fixed, but I get this warning on my site:
Warning : asort() expects parameter 1 to be array, null given in sorttaxonomy_form_views_exposed_form_alter() (line 4 in /home/mysite/public_html/sites/all/modules/_custom/sorttaxonomy/sorttaxonomy.module).
line 4 is for
if($fid = $filter->options['expose']['identifier']) asort($form[$fid]['#options']);
Any idea?
Comment #6
morybel CreditAttribution: morybel commentedAlso, is there a way I can target only one filter box with this function? I have several other exposed filter that doesn't need to be sorted that way. Thanks for any help.
Comment #7
morybel CreditAttribution: morybel commentedWell, a little search and I got my answer,
I found a solution here http://drupal.stackexchange.com/questions/149015/7-sorting-a-views-expos...
This is my adapted code :
views-exposed-form-search-profile-page is the name of my views
tid_i18n_4 is the name of my filter
Hope it helps someone.