Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I wanted distinct taxonomy terms, so I could get a list of terms that have nodes. Attached is my solution.
Comment | File | Size | Author |
---|---|---|---|
views_taxonomy.inc_.patch | 1.61 KB | konsumer | |
Comments
Comment #1
konsumer CreditAttribution: konsumer commentedIf anyone could review this, and let me know if it makes sense, that'd be awesome.
Comment #2
martink CreditAttribution: martink commentedI 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?
Comment #3
kirby CreditAttribution: kirby commentedI 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.
Comment #4
ruanyf CreditAttribution: ruanyf commentedkirby, you must add the filter "Taxonomy: Vocabulary Name" at the same time, then it will work.
Comment #5
kirby CreditAttribution: kirby commentedIt perfectly makes sens. it works now.
Thank you very much ruanyf.
Comment #6
xentek CreditAttribution: xentek commentedPatch worked for me. This should be incorporated into the official release.
Comment #7
martink CreditAttribution: martink commentedPatch worked for me to I agree that this would be great in the official release
Comment #8
xentek CreditAttribution: xentek commentedNow we just need COMMENT: DISTINCT and we'll be set :)
Comment #9
xentek CreditAttribution: xentek commentedRe: 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!
Comment #10
lee20 CreditAttribution: lee20 commentedPatch 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!
Comment #11
WorldFallz CreditAttribution: WorldFallz commented+ 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...
Comment #12
konsumer CreditAttribution: konsumer commentedIf 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.
Comment #13
WorldFallz CreditAttribution: WorldFallz commentedyep... 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...
Comment #14
vanderlip CreditAttribution: vanderlip commentedKonsumer - Thanks a lot! This works like a charm and solved my problem. Much appreciated.
Comment #15
joel_guesclin CreditAttribution: joel_guesclin commentedAny chance of this getting into standard Views, it is so useful!!
Comment #16
enkara CreditAttribution: enkara commentedI 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!
Comment #17
sunSorry, Views 1.x will not have any new major features. Consider upgrading to 6.x, please.
Comment #18
gthing CreditAttribution: gthing commentedAww please?