Problem/Motivation

Taxonomy is listed according to field delta and not the weight assigned in taxonomy admin screens. This is inconsistent and (I believe) is wrong for a number of reasons. These are:

  • Allowing taxonomy admins to order tags in the administration theme implies this will have an effect. For nodes with vocab fields using the autocomplete term widget it never does – for the other form elements available (eg. select list) it does but only after the node is re-saved.
  • The order in which terms are listed on edit and view is inconsistent – if the autocomplete term is used terms are listed in the order entered by the node creator/editor – for the other options they are list in order of weight at the time of content creation.
  • Other CMS's free tagging systems obey alphabetical order – I believe this is natural for free tagging and we are now making this impossible to achieve with vanilla Drupal where as it was out-of-the-box with D6.

Steps to reproduce

In order to recr

  1. Create an article type node with "mongoose, zebra, aardvark" in the free tagging field and save
  2. View the node... the order is "mongoose, zebra, aardvark"
  3. Go to the taxonomy list screen for the default vocab you will see that the terms are in alphabetical order
  4. Change it to any other order (except the order entered in the field) e.g. Zebra, Mongoose, Aardvark
  5. Go back to the created article - you will see it has no effect

Proposed resolution

TBD

Remaining tasks

Decide if the node view should order the terms by weigth

User interface changes

API changes

Data model changes

Release notes snippet

Comments

alexpott’s picture

StatusFileSize
new3.22 KB

Patch attached to fix the issue

radicsge’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 815682_term_order.patch, failed testing.

alexpott’s picture

Status: Needs work » Needs review

#1: 815682_term_order.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 815682_term_order.patch, failed testing.

alexpott’s picture

StatusFileSize
new2.49 KB

Old patch posted with unnecessary code :(

New patch attached to solve issue.

alexpott’s picture

Status: Needs work » Needs review
xjm’s picture

hass’s picture

Priority: Normal » Major
Niklas Fiekas’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs review » Needs work

Thanks @alexpott for the detailed steps to reproduce and the patch. The same seams to occur in Drupal 8. The policy is to get things into D8 first and then move the issue back to 7.x for backporting. Setting needs work for a reroll.

Note: If we can (by any chance) do the ordering on the database layer, that would be preferable.

Code review: Comments should always end with a . and wrapped at 80 characters. The summary line of sorting callbacks would be like the example in http://drupal.org/node/1354#callbacks.

marcingy’s picture

Priority: Major » Normal

This is not major

jthorson’s picture

Hasn't been major for two years ... fail to see what has changed now, to make it so.

hass’s picture

Priority: Normal » Major

As nobody is working on this issue it seems to have a wrong priority. Highering priority to get the major bug fixed. It's not possible to order taxonomies, this is really major. I would like using critical, but it's not critical.

catch’s picture

Priority: Major » Normal

Whether or someone is working on an issue is not the measure of its priority, see http://drupal.org/node/45111 for what is.

ryan.ryan’s picture

Assigned: Unassigned » ryan.ryan

I'm on it.

ryan.ryan’s picture

Assigned: ryan.ryan » Unassigned
Status: Needs work » Needs review
StatusFileSize
new2.49 KB

Attached is the patch. I tested the functionality and it worked.

Status: Needs review » Needs work

The last submitted patch, 815682_term_order_0.patch, failed testing.

jthorson’s picture

Status: Needs work » Needs review
StatusFileSize
new2.3 KB

Re-rolled to apply against latest head. (Was the original rolled against D7, perhaps?)

dcam’s picture

#18: 815682_term_order-reroll.patch queued for re-testing.

dcam’s picture

#18 still applies to D8. After applying, taxonomy terms are displayed in node views by order of their weights in the admin term list page (tested with all three term widgets).

+1 for RTBC. It seems like a good idea to me, but hopefully a more experienced core contributor will check this since it's a UI change.

dcam’s picture

#18: 815682_term_order-reroll.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 815682_term_order-reroll.patch, failed testing.

kerasai’s picture

Is it not a benefit to have the flexibility to set an arbitrary order (delta as set by user) on the terms of a node/entity? I certainty think it is. Maybe some type of configuration to determine which behaviour is appropriate.

xjm’s picture

Issue tags: +Needs tests, +Needs reroll

Let's see if this is still reproducible in current D8. We also will need an automated test demonstrating the bug, if so.

Mandakini_Kumari’s picture

Status: Needs work » Needs review

#6: 815682_term_order.patch queued for re-testing.

xjm’s picture

Status: Needs review » Needs work

@Mandakini_Kumari, the patch you requeued was from 2010, before Drupal 7 was released, so there is no way it will work for Drupal 8. :) To see if this is reproducible in D8, we need to test it by hand in a Drupal 8 installation, and then the next step will be to code a new automated test covering the bug.

Mandakini_Kumari’s picture

Assigned: Unassigned » Mandakini_Kumari

@xjm: Sure I will start working on it.

Mandakini_Kumari’s picture

StatusFileSize
new50.98 KB

I tested and found that it is reproducible in D8. Attached here is screen shot.
Taxonomy display order

xjm’s picture

Thanks @Mandakini_Kumari!

alexpott’s picture

@Mandakini_Kumari hmmm... seems like you've discovered a vocabulary ordering issue. The original issue is concerned with the ordering of taxonomy terms within a free tagging vocabulary.

Re-testing on Drupal 8 shows we are even more inconsistent!

In order to recreate this issue with a vanilla drupal standard install:

  1. Create an article type node with "mongoose, zebra, aardvark" in the free tagging field and save
  2. View the node... the order is "aardvark, zebra, mongoose" (i.e. the reverse order to which the terms are entered)
  3. Go to the taxonomy list screen for the default vocab you will see that the terms are in alphabetical order
  4. Change it to any other order (except the order entered in the field) eg. Zebra, Mongoose, Aardvark
  5. Go back to the created article - you will see it has no effect
Mandakini_Kumari’s picture

StatusFileSize
new48.45 KB

I am wounding is there any relation between field weight of table taxonomy_term_data and Admin UI of admin/structure/taxonomy (Home >> Administration >> Structure) ?

Attached screen shot for both.Relation between taxonomy_term_data and Taxonomy Admin UI

Field weight of table taxonomy_term_data having always 0 value but Admin UI shows taxonomy weight and sequence of display. In D6 both weight were synch. Please help me to understand

xjm’s picture

@Mandakini_Kumari, the first screenshot shows the term data table, but the second screenshot shows the weight of vocabularies. These are two different things. For example you might have:

Vocabulary A -- weight 5

  • Term A1 -- weight 0
  • Term A2 -- weight 0

Vocabulary B -- weight 9

  • Term B1 -- weight 1
  • Term B2 -- weight 2
pwieck’s picture

Issue tags: -Needs reroll

removing reroll tag

utilum’s picture

Assigned: Mandakini_Kumari » utilum
utilum’s picture

  1. Step 2 to reproduce the issue not reproduced locally. On viewing the node I see the terms in the order they were input (attaching screenshots). When I change the order of terms from the node edit form, viewing the node displays terms in the order I've edited them.
  2. Steps 3-5 more than reproduce: Changing the order on the vocabulary admin interface has no effect on the order in which the terms are displayed in node view, not even resetting to alphabetical.
  3. I'd like to write a test, but reading through this issue and the cross-references in #8 I'm not sure what behavior is expected...

Current behavior: Node view displays terms in the order entered on the node form. Weight changes in the vocabulary admin interface affect only the widget display; the order of terms in node view is not affected. However, if the widget is checkboxes or select list, opening the node edit form and saving without making any edits will enter terms sorted by weight, and therefore display them accordingly.
Does this require fixing?
If so, would someone help me lay out the desired behavior to test against?

utilum’s picture

Issue summary: View changes

Changing instructions for what to look for in Drupal 8. And removing drupal version references.

mgifford’s picture

Assigned: utilum » Unassigned
drupalfan2’s picture

I had the same problem and this patch seems to solve the problem.

Is this patch
https://www.drupal.org/files/815682_term_order-reroll.patch
implemented in Drupal 7.41?

If not, why not?

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

ressa’s picture

This is still an issue in the latest release Drupal 8.2.2 - taxonomy terms seem to be sorted randomly, and not according to the order of the Term List page at admin/structure/taxonomy/manage/tags/overview.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

tim corkerton’s picture

This is still an issue with the latest Drupal 8.9.4. Experiencing the same behaviour as described.
Also Patch fails to apply

danflanagan8’s picture

I wanted to pop in and point out that the contrib module Entity Reference Extensions can handle displaying the terms in a Taxonomy Reference field sorted by weight (or by any other property/field of the terms).

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Version: 9.5.x-dev » 11.x-dev
Issue summary: View changes
Issue tags: +Bug Smash Initiative, +Usability

I tested this on Drupal 11.x, standard install and I was able to reproduce some of the problem

  1. Create an article type node with "mongoose, zebra, aardvark" in the free tagging field and save
  2. View the node... the order is "aardvark, zebra, mongoose" (i.e. the reverse order to which the terms are entered). This is not longer true. The tags are in the order entered.
  3. Go to the taxonomy list screen for the default vocab you will see that the terms are in alphabetical order
  4. Change it to any other order (except the order entered in the field) eg. Zebra, Mongoose, Aardvark
  5. Go back to the created article - you will see it has no effect

So the issue is now that when viewing a node, the order of the tags is not the same as the ordering of the vocabulary.

I am updating the steps to reproduce

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.