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.
I made a patch that works for my situation and by lack of time I was unable to further develop this patch.
So.. Hoping that other people can do anything useful with this patch. What is does is it removes the automatic sorting that is implemented in hierarchical select.
Pay attention : I only tested this with taxonomy terms. No guarantee!
Comments
Comment #1
Wim LeersSorry Nick, but this patch is worthless. And a mess, too.
You've got whitespace changes that make the whitespace incorrect. You've changed the #submit callback stuff, which will result in erroneous behavior. You're adding commented code. And it can only ever work for Taxonomy, because you're using Taxonomy's API. "I only tested this with taxonomy terms" is quite an understatement.
Please do better next time … :)
Comment #2
jrstmartin CreditAttribution: jrstmartin commentedI'm also looking for a way to control the default (alphabetical) sorting of the dropbox. In my case, I use HS to force the user to select a category (via taxonomy) to submit their content into. Then, based on the category (taxonomy terms) they choose, Pathauto generates a nice URL with the [save-lineage-vid-termpath-raw] patch.
My problem is when I allow users to select multiple categories (add multiple selections to the dropbox). Pathauto will generate the URL using the first dropbox entry, which is always sorted alphabetically. In this case, there is no way to allow the user control over how the URL is generated. If they want to select multiple categories, but want to control how the URL is generated for navigation and SEO purposes, they can't if the category is alphabetically lower than another category in the dropbox.
I think this could be solved in HS if the order of things in the dropbox stayed in the order that they were added to the dropbox. That way, I could just put some help text saying, "URL is generated from the first category that is chosen." Can anyone suggest a way to accomplish this?
I'm reluctant to use the patch above due to the maintainer's comment and I know jack about PHP.
I realize this may seem abstract to some, but it makes sense to me for categorization, navigation, URL, and SEO purposes. I'm not sure if this is really a taxonomy/pathauto issue or if it's best to be solved in HS?
Thanks for such a great module!
Comment #3
davidwhthomas CreditAttribution: davidwhthomas commentedHi sorry to re-open an old issue, but I think this one could use some work.
Problem still occurs in D7 branch.
Having the ability to remove the automatic sort in the drop box is quite worthwhile.
For example, if a story has multiple categories, an editor needs to choose one 'main' home category for the article.
The obvious way to do that is use the first selected term as the main term.
However, with dropbox enabled, adding a new term to the dropbox currently reorders the list, pushing the 'main' term to the end, instead of appending the new term to the end..
It looks like the simple fix for this at the moment is to comment out
hierarchical_select.module
But it'd be nice to have this as a config setting somewhere for the field.
cheers,
David
Comment #4
davidwhthomas CreditAttribution: davidwhthomas commentedOK, here's the goods.
A small patch to provide a dropbox "Sort" setting and apply the sort based on that setting.
Cheers,
DT
Comment #5
davidwhthomas CreditAttribution: davidwhthomas commentedComment #6
davidwhthomas CreditAttribution: davidwhthomas commentedAdditional patch adjusted for coding standards and to ensure existing sort functionality is preserved as default, even when new setting form is not yet checked.
Comment #7
Wim LeersHmm … I can see how this can be necessary in some cases. I'd oppose to this if only for the reason of adding yet another setting, but I guess this one doesn't hurt, because it is *so* clear/obvious.
The code looks good. The only thing that's missing at this point, I think, is support for exporting HS configs with this setting. (Importing works automatically.) For that, you'll need to add a one-line change to
_hierarchical_select_create_export_code()
inhierarchical_select.admin.inc
. And of course, add it toAPI.txt
.After that, this seems good to go :) Thanks for the contribution!
Comment #8
Daniel Schaefer CreditAttribution: Daniel Schaefer commentedThanks for the patch, David. Works for me.
Any plans for pushing the patch into the next releases? I wish I could help with the to-do proposed by Wim Lees.
Comment #9
firfin CreditAttribution: firfin as a volunteer and commentedAt least related, possible duplicate.
Comment #10
firfin CreditAttribution: firfin as a volunteer and commentedI updated the patch to apply to current dev. Also added the suggested edits to API.txt and hierarchical_select.admin.inc.
Unfortunately unchecking the box does not seems to change anything in the sorting.
Any ideas?
Comment #11
firfin CreditAttribution: firfin as a volunteer and commentedComment #12
firfin CreditAttribution: firfin as a volunteer and commentedIt DOES work by the way, I made a mistake while testing that's why it didn't seem to work for me at first.
Comment #14
stefan.r CreditAttribution: stefan.r commentedIt took 7 years, but...
...committed, thanks!
Comment #16
kirankkaran CreditAttribution: kirankkaran commentedI am experiencing the same issue in drupal 8.
I am selecting fields and while saving it and viewing it I get to see that the terms are arranged in the alphabetical order.
Any lead to the same?