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
Description

I wanted distinct taxonomy terms, so I could get a list of terms that have nodes. Attached is my solution.

AttachmentSize
views_taxonomy.inc_.patch1.61 KB

#1

konsumer - January 5, 2008 - 06:59
Assigned to:Anonymous» konsumer

If anyone could review this, and let me know if it makes sense, that'd be awesome.

#2

martink - January 8, 2008 - 11:17

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

kirby - January 18, 2008 - 13:37

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

ruanyf - January 19, 2008 - 05:18

kirby, you must add the filter "Taxonomy: Vocabulary Name" at the same time, then it will work.

#5

kirby - January 21, 2008 - 22:43

It perfectly makes sens. it works now.
Thank you very much ruanyf.

#6

xentek - January 23, 2008 - 19:56
Status:needs review» reviewed & tested by the community

Patch worked for me. This should be incorporated into the official release.

#7

martink - January 24, 2008 - 11:15

Patch worked for me to I agree that this would be great in the official release

#8

xentek - February 8, 2008 - 22:33

Now we just need COMMENT: DISTINCT and we'll be set :)

#9

xentek - February 8, 2008 - 23:07

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

lee20 - March 21, 2008 - 03:45

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

WorldFallz - May 4, 2008 - 00:51

+ 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

konsumer - May 6, 2008 - 21:48

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

WorldFallz - May 7, 2008 - 01:00

So what you should be getting is a list of all terms that have nodes assigned to them, listed only once.

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

vanderlip - May 21, 2008 - 21:31

Konsumer - Thanks a lot! This works like a charm and solved my problem. Much appreciated.

#15

joel_guesclin - December 21, 2008 - 00:24
Version:5.x-1.x-dev» 5.x-1.6

Any chance of this getting into standard Views, it is so useful!!

#16

enkara - January 7, 2009 - 09:39

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

sun - February 21, 2009 - 03:47
Status:reviewed & tested by the community» won't fix

Sorry, Views 1.x will not have any new major features. Consider upgrading to 6.x, please.

#18

gthing - February 24, 2009 - 07:09

Aww please?

 
 

Drupal is a registered trademark of Dries Buytaert.