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.. :)
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | taxonomy_vocab_weight_2.patch | 901 bytes | grohk |
| #7 | taxonomy_vocab_weight.patch | 901 bytes | grohk |
| #3 | taxonomy.module_3.patch | 872 bytes | MrRoot |
| taxonomy.module_2.patch | 866 bytes | MrRoot |
Comments
Comment #1
MrRoot commentedAck - that patchfile was generated against the current CVS tree, so I suppose the Version should have been 'cvs'? Sorry about that if it was misplaced.
Comment #2
moshe weitzman commentedthis 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.
Comment #3
MrRoot commentedAh.. 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 tables.
Cheers
Comment #4
dries commentedIs 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.
Comment #5
killes@www.drop.org commentedPatch doesn't apply.
Comment #6
jonbob commentedComment #7
grohk commentedI 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 suggestions.
Comment #8
grohk commentedAs per a suggestion Moshe made in an email, I have updated this patch to order by vocabulary weight then term weight.
Comment #9
dries commentedCommitted to HEAD. Thanks.
Comment #10
(not verified) commented