The Taxonomy Lineage module adds a table to the taxonomy database which allows nodes to be sorted by taxonomy hierarchy. The module adds no new sort function by itself, so simply adding this module will not add functionality. However, it can be used with the Views module, and PHP snippets or custom code may be written to sort, as well.
- Problem
- The taxonomy hierarchy system, while powerful, cannot easily generate lists of nodes sorted by hierarchy depth.
For example, with a hierarchy structured like:Parent 1
Child 1
Sub-child 1
Child 2
Sub-child 2
Sub-child 3
Parent 2
...
It is very difficult to get those nodes in the right order. So much so, in fact, that it requires a recursive query algorithm. - Solution
- In order to solve this, research suggests that an effective solution is the Nested Trees method. An essence, each taxonomy term needs a single field that describes the entire hierarchy in a way that is sortable. The following patch implements such a solution.
- Implementation
- The patch creates a new table,
term_lineagewhose sole purpose is to store the hierarchy in a single field. In order to make the field sortable, for each node in the hierarchy a string is constructed. The first part of the string is the term's weight (plus an offset to eliminate negative numbers). The second part is the term's name. 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.When a taxonomy term is updated, its lineage and the lineage of all of its children must be updated. If a taxonomy hierarchy is particularly large, this might be a noticeably slow process, but with a moderate sized hierarchy it took very little time on my system.
Note about the 6.x-1.x-dev branch
The current development branch uses a modified data format to correct a Drupal 6.x compatibility issue (#507472: Fix weight string handling for D6). If you upgrade from a previous version to the current dev build (Nov. 2009 or later), disable and re-enable the module so that lineage's data is re-generated in the new format.
About the Developers
This project is maintained by Agileware Pty Ltd, http://www.agileware.net. Please contact them if you require a Drupal theme, custom Drupal module development, Drupal systems integration or have a complex Drupal project. They love Drupal!
Downloads
Recommended releases
Development releases
Project Information
- Maintenance status: Seeking co-maintainer(s)
- Development status: Maintenance fixes only
- Reported installs: 704 sites currently report using this module. View usage statistics.
- Last modified: December 3, 2011