[drupal-devel] [feature] Order taxonomy terms by vocabulary weight, then term weight

grohk drupal-devel at drupal.org
Sun May 8 07:16:59 UTC 2005

Issue status update for http://drupal.org/node/7684

 Project:      Drupal
 Version:      cvs
 Component:    taxonomy.module
 Category:     feature requests
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  MrRoot
 Updated by:   grohk
-Status:       active
+Status:       patch
 Attachment:   http://drupal.org/files/issues/taxonomy_vocab_weight.patch (901 bytes)

I have been looking for this funtionality for a long time, so I have
attempted to bring this patch up-to-date and clean it up as per the


Previous comments:

May 10, 2004 - 21:33 : MrRoot

Attachment: http://drupal.org/files/issues/taxonomy.module_2.patch (866 bytes)

This is a trivial patch to the taxonomy_node_get_terms() function. 
Currently, it was only sorting the results by term weight; the patch
joins in the vocabulary table and adds the vocabulary weight as a
second preference ordering.

I wrote this because I wanted to force ordering of vocabularies when
listing the taxonomies of a node using the taxonomy_link() function. 
Basically, what I was doing was this: I created a "Story Type" vocab
which described the overall *type* of post ( News, Rant, Review, ... )
and a "Topic" vocab which described the *topic* of the post (
Programming, Math, Political, Family, ... ).  Now, when you added a new
story, you picked a Story Type and a Topic.  When the story is
displayed, it shows the taxonomy assignments as a list of links.  The
ordering of that list was by term weight, term name.  That meant that
if I wanted to control the left to right layout of that information,
I'd have to set the weight on every term in each vocabulary.  That
seemed tedious, especially since the vocabularies themselves already
had a weight associated with them.  Hence, I dug around for about 15
minutes and wrote this patch.

It's been tested and seems to work quite well.  I can now *force* which
taxonomy vocabulary is listed when, and thereby always make the posts
appear as "Story Type | Topic".

Hope it's useful..  :)


May 10, 2004 - 21:40 : MrRoot

Ack - that patchfile was generated against the current CVS tree, so I
suppose the Version should have been 'cvs'?  Sorry about that if it was


May 10, 2004 - 22:48 : moshe weitzman

this patch makes a lot of sense ... however, your sql is non standard
for drupal. we use the x JOIN y ON x.field = y.field syntax. Your SQL
doe snot use this JOIN syntax. Please resubmit and then I'll bet that
this will be accepted into core.


May 10, 2004 - 23:47 : MrRoot

Attachment: http://drupal.org/files/issues/taxonomy.module_3.patch (872 bytes)

Ah..  I was wondering about that..  Looks like most of the rest of
taxonomy.module does not make use of JOIN statements.  So I was
following that.  Anyhow, I updated the patch to use JOIN on all of the



May 11, 2004 - 16:15 : Dries

Is that ANSI SQL?  If these are 'left' joins, please use 'LEFT JOIN'. 
If these are 'inner' joins, please use 'INNER JOIN'.  Also, I'd add a
small comment to code to explain the rationale behind that query.


August 12, 2004 - 11:28 : killes at www.drop.org

Patch doesn't apply.

More information about the drupal-devel mailing list