Taxonomy Term distinct
konsumer - November 27, 2007 - 18:36
| Project: | Views |
| Version: | 5.x-1.6 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | konsumer |
| Status: | won't fix |
Jump to:
Description
I wanted distinct taxonomy terms, so I could get a list of terms that have nodes. Attached is my solution.
| Attachment | Size |
|---|---|
| views_taxonomy.inc_.patch | 1.61 KB |

#1
If anyone could review this, and let me know if it makes sense, that'd be awesome.
#2
I think that I am trying to do the same thing: that is to say, I want to design a block which displays the taxonomy terms associated with the most recent articles. Problem is, as far as I can see with Views 5.x-1.6, if several nodes have been classified under the same term then the term appears twice in the block. Is this what this patch is supposed to allow you to do?
I'm not qualified to validate the patch, but I think if you want to get it validated (and better still integrated into the next version of Views), then you need to give a lot more detail in your post: rationale behind the patch, what it allows you to do that you cannot do already, what is changed in the UI and the code. Also, is it an error that the patch is posted against version 5.x-1.x-dev? Should it not better be against 5.x-1.6 which is the latest stable version as I understand it?
#3
I edited myself the file with your patch/diff file and here is the SQL error which is displayed :
user warning: Unknown column 'term_data.tid' in 'group statement' query: SELECT DISTINCT(node.nid) FROM node node GROUP BY term_data.tid LIMIT 0, 10 in C:\wamp\www\mysite\includes\database.mysql.inc on line 172.I'm pretty sure I modified correctly the file.
#4
kirby, you must add the filter "Taxonomy: Vocabulary Name" at the same time, then it will work.
#5
It perfectly makes sens. it works now.
Thank you very much ruanyf.
#6
Patch worked for me. This should be incorporated into the official release.
#7
Patch worked for me to I agree that this would be great in the official release
#8
Now we just need COMMENT: DISTINCT and we'll be set :)
#9
Re: Comment Distinct
I created a patch file to views_comment.inc that will add Comment:Distinct functionality. You can find it here: http://drupal.org/node/219499
Thanks goes to this patch author, as I used it as guide when developing mine! Props to konsumer!
#10
Patch worked for me as well. Unfortunately I switched to using node reference instead of taxonomy. If only I can find a Node Reference Distinct filter now!
#11
+ 1. Patch applies cleanly and does what it says.
unfortunately, I can't seem to generate a simple list of distinct taxonomy terms.
I'm getting a list of terms for each node (1 node per row of terms), not a list of distinct terms.
I'm creating a page view as follows: "Taxonomy: Terms for " as the only field and "Taxonomy: Vocabulary Name" and "Taxonomy: Term Distinct" as the only filters. Nothing else it set.
What am I doing wrong?
Any insight would be greatly appreciated!
Thanks...
#12
If what you mean is that you want to get a list of terms, not attached to nodes, this is not what the patch provides. It's just a filter to show a term only once that is attached to a node. I think this is a basic part of how views works (everything is attached to a node.)
So what you should be getting is a list of all terms that have nodes assigned to them, listed only once.
This is useful, for example, for a catalog that uses taxonomy to categorize products. It will only show categories that have products in them.
If you mean something else, let me know, and I will have a look at your view.
#13
yep... that's what I'm after--- I'm still learning my way around views, but Ive been doing some reading on d.o. and i think I need to use one of the summary options. maybe that's what I'm doing wrong. I don't have access to my system atm, but i'll give it another shot...
#14
Konsumer - Thanks a lot! This works like a charm and solved my problem. Much appreciated.
#15
Any chance of this getting into standard Views, it is so useful!!
#16
I have a problem with this patch. When creating a view with pager, it counts all the items inside the categories, if as the view was without that filter. For example if I have two taxonomy terms with 14 items inside in total and the max items per page is 10, the pager is displayed and there are only two terms there...
Has someone found this and has fixed it? I would be fantastic for me.
Thank you very much!
#17
Sorry, Views 1.x will not have any new major features. Consider upgrading to 6.x, please.
#18
Aww please?