I'm trying to display simple list of terms from two depths like this:

- parent 0
- parent 1
- child 1.1
- child 1.2
- parent 2
- child 2.1
- child 2.2

What I get is:

- parent 0
- child 1.1
- child 1.2
- parent 1
- child 2.1
- child 2.2
- parent 2

Below is Term: hierarchy example which clearly shows that it considers following as ascending ordering where obviously it shouldn't.

017-Rowery012-Rowery szosowe
017-Rowery014-Rowery full suspension019-Enduro
017-Rowery014-Rowery full suspension020-Cross Country FSX
017-Rowery014-Rowery full suspension

should be:

017-Rowery012-Rowery szosowe
017-Rowery014-Rowery full suspension
017-Rowery014-Rowery full suspension019-Enduro
017-Rowery014-Rowery full suspension020-Cross Country FSX

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

philipz’s picture

I've found that this is due the new line character in lineage column. Maybe this could be changed to double underscore ("__") ? This fixes the problem. The project page says:

The third part is a carriage return, which is a character almost guaranteed not to be in the term name and will sort ahead of all possible characters that will be in the title.

but this is not true. It is guaranteed not to be in the term name but does not sort ahead and I don't understand why it's such emphasis on the character not being in term's name?

philipz’s picture

Status: Active » Needs review
FileSize
424 bytes
joachim’s picture

> It is guaranteed not to be in the term name but does not sort ahead and I don't understand why it's such emphasis on the character not being in term's name?

This is needed because if the character is found in term names, then the term names themselves will affect the order.

Eg if I have:

- 'foo::bar'
- 'foo'
-- 'bar'
--- 'biz'

and my separator is '::' then the term that's called 'foo::bar' will interfere with the order.

I think the right fix here is to append the newline to the lineage.

joachim’s picture

The code currently trims the newline off the end of the lineage.

If we skip this, then terms sort correctly.

Abelito’s picture

Status: Needs review » Reviewed & tested by the community

This patch works, thank you.
However, make sure you uninstall Taxonomy Lineage, then reinstall it with the patch, or your hierarchy wont be updated properly.

Tested on: Views 7.x-3.14
Drupal 7.53, PHP 5.5.24
Drupal 7.52, PHP 5.6.28