Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.6
Component:
taxonomy data
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
6 Aug 2009 at 05:57 UTC
Updated:
4 Oct 2009 at 07:04 UTC
Jump to comment: Most recent
Comments
Comment #1
dawehnerYou need a view type: taxonomy, for listing taxonomy terms.
Comment #2
Anonymous (not verified) commentedActually that doesnt exactly do it
I have recently had the same problem. I wanted a list of Authors Names which were in a taxonomy , which i would then use the name as the argument in a second view so when i selected the name i got the page for the other view.
If you use the view type taxonomy it returns all taxonomy terms, including those with "0" results what xn 2001 wants is only those where there are results , ie used in nodes published
So First a feature to ignore those without taxonomy entries ie zero, for taxonomy views would be great
Alternatively the way i found to eliminate the duplicates is as follows, but you cant display it as a grid, you get a single column
Are we sitting comfortably ?
Basic Settings - row style - fields
Fields - Taxonomy Term
Basic Settings - style - Grid settings - Goup on Taxonomy Term
In your Filters select Node Published Yes and anything else you want
Comment #3
xn2001 commented@dereine
No, I can't set the view type to taxonomy term because I need to set node filter to Published. When using "Taxonomy term" view type, informations about the node are not exposed. Therefore, I have to use Node view type.
@midkemia
Your suggestion doesn't work. Actually, it is getting worst. By grouping on Taxonomy Term, I first get the group name and also the duplicate terms.
Anyone has other suggestions?
Comment #4
Anonymous (not verified) commentedDid you just look at the preview or the view results?
You will see the duplicate terms in preview, but not in the actual page view. OK thats what happens in my case
EDIT : just remembered i also themed
views-view-grid--myview--page.tpl.php
So I guess i cheated to get rid of the surplus
Comment #5
xn2001 commented@midkemia
I looked at both, the preview and the results views. They both showed the duplicate terms. Your suggestion doesn't satisfy my need as it forces all terms into 1 columns. I want to show terms in 4 columns.
Is there a hook where I can remove the duplicates before the results are submitted to view?
Comment #6
xn2001 commentedOk, I finally resolved my issue by using hook_views_pre_render(&$view) to remove duplicate terms before view is rendered. I think it is much elegant than other workarounds.
Comment #7
olafveerman commentedCan you provide a bit more detail as to how solved it? It might benefit others that have the same problem, myself included.
Comment #8
xn2001 commented@oBirdman
What I did was:
In hook_views_pre_render(&$view), I loop through $view->result array and check whether the next term is the same as the current term. If it is, then I remove the array index. Otherwise, go to the next term.
Note: What I did is not full proof. Duplicate terms are removed but not replaced. If you set 10 terms per page and 10 of them are the same terms, then you get a page with only 1 term because the remaining 9 are duplicates.
Comment #9
pharma commentedWhen you first create a view, select Taxonomy Terms as the type instead of Node.
http://drupal.org/node/350977#comment-1174041
Comment #10
Anonymous (not verified) commentedpharma #9 see derine's response #1
Also my response in 2, your suggested method does not meet the requirement.
Using your method a Taxonomy Term with zero results is still returned.
It also does not take account where a Taxonomy is used across multiple content types and the results of only 1 content type is needed