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!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Status: Active » Closed (won't fix)

Sorry 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 … :)

jrstmartin’s picture

I'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!

davidwhthomas’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Closed (won't fix) » Active

Hi 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

usort($dropbox->lineages, '_hierarchical_select_dropbox_sort');

But it'd be nice to have this as a config setting somewhere for the field.

cheers,

David

davidwhthomas’s picture

OK, here's the goods.

A small patch to provide a dropbox "Sort" setting and apply the sort based on that setting.

Cheers,

DT

davidwhthomas’s picture

Status: Active » Needs review
davidwhthomas’s picture

Additional patch adjusted for coding standards and to ensure existing sort functionality is preserved as default, even when new setting form is not yet checked.

Wim Leers’s picture

Status: Needs review » Needs work

Hmm … 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() in hierarchical_select.admin.inc. And of course, add it to API.txt.

After that, this seems good to go :) Thanks for the contribution!

Daniel Schaefer’s picture

Thanks 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.

firfin’s picture

At least related, possible duplicate.

firfin’s picture

I 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?

firfin’s picture

Status: Needs work » Needs review
firfin’s picture

It DOES work by the way, I made a mistake while testing that's why it didn't seem to work for me at first.

  • stefan.r committed ec86c15 on 7.x-3.x authored by firfin
    Issue #466828 by davidwhthomas, firfin, Nick_vh: Disable the automatic...
stefan.r’s picture

Status: Needs review » Fixed

It took 7 years, but...

...committed, thanks!

Status: Fixed » Closed (fixed)

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

kirankkaran’s picture

I 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?