I just installed this module, in hopes of being able to create a view that was separated into two groups by taxonomy vocabulary - basically, what I wanted was a small heading with the name of the first vocabulary, then a list of the terms in it (each linked to the corresponding page), then a heading with the name of the second vocabulary and a similar list of its terms. Seemed like it ought to be simple, in theory...
So I added SQL aggregation to the fields for the view, and picked Taxonomy: Vocabulary Name as the term to group on, and Taxonomy: Term as the field to aggregate and sort on (so that the resulting lists would be ordered by term). I thought that was the right way to do it... But when I clicked Update, I got the following error message:
user warning: Can't group on 'term_data_name' query: SELECT term_data.tid AS tid, COUNT(term_data.name) AS term_data_name, term_data.vid AS term_data_vid, vocabulary.name AS vocabulary_name FROM term_data term_data LEFT JOIN vocabulary vocabulary ON term_data.vid = vocabulary.vid GROUP BY vocabulary_name, term_data_name, tid, term_data_vid ORDER BY term_data_name ASC, term_data_name ASC in /[my web directory]/sites/all/modules/views/includes/view.inc on line 769.
This is more convoluted SQL than I am used to dealing with, but as far as I can tell, it looks like it's trying to group on term as well as vocabulary, and by both ID and name for each of those, which is not what I told it to do. I just want it to group the terms by which vocabulary they belong to.
Am I doing something wrong? Or is this a bug of some sort?
(I've set the priority as critical on this because this site is supposed to be done very soon and the view I'm trying to group is a very central part of the site, so it's essential that I get this working ASAP. And right now, trying to group it breaks the view completely.)
Comments
Comment #1
knystrom commentedObservations:
- It looks like you're trying to do a count, but you're description doesn't indicate this is what you want.
- If you don't need a count, consider http://drupal.org/project/tablegroup
- The error in your sql is that the aggregated field (term_data_name in this case) cannot be in the group_by clause. The example on the module page is pretty clear and sounds like it's what you're doing. Try stepping thru it again making sure you have the order of fields and sort right: http://drupal.org/node/389230.
This runs:
SELECT
term_data.tid AS tid, COUNT(term_data.name) AS term_data_name,
term_data.vid AS term_data_vid, vocabulary.name AS vocabulary_name FROM
term_data term_data LEFT JOIN vocabulary vocabulary ON term_data.vid =
vocabulary.vid GROUP BY vocabulary_name, tid,
term_data_vid ORDER BY term_data_name ASC, term_data_name ASC
kim
Comment #2
spidersilk commentedNo, I don't particularly need a count - I just want my results grouped. I thought from the module name that that was what this one was supposed to do, but it seems like it's more about counting, and I'm not really sure why.
I looked at tablegroup, though I'd really prefer not to have my results in a table. All I'm trying to do is list taxonomy terms, each linked to its page - it's not tabular data, and I know it's generally considered bad practice to use tables purely for layout purposes. All I need is a simple unordered list for each group, with the name of the vocabulary above it. It doesn't even look like tablegroup will do that - as far as I can tell, it puts all the results in one table, so you can't have headings for the individual groups. But I will download it and give it a try.
Getting back to this module, I can see what's wrong in the SQL it's generating - I just can't see why it's doing that. Term is NOT selected in the "Fields to group by" menu, but for some reason the module is insisting on trying to group by it anyway. The only field that is selected in that menu is Vocabulary Name. Here is exactly what I have in my settings:
Shouldn't that, theoretically, give me a list of taxonomy terms grouped by vocabulary? Or am I completely misunderstanding how this works?
I don't actually need it to count anything, and I'm not even sure what in this instance it would try to count. I did read the tutorial first, but since it was trying to do something completely different, I had to sort of mentally translate, and evidently I've done that incorrectly in some way.
Comment #3
spidersilk commentedBTW, the purpose behind what I'm doing, in case that helps any, is a portfolio of writing samples on a copywriter's site. All the samples are categorized using two different vocabularies - industry (financial, technology, medical, etc.) and type of work (brochure, direct mail, web site, etc.). So I'd like to allow people to browse the portfolio either by industry or by type of work, by having two lists of categories on the main portfolio page.
Does that make what I'm trying to do make any more sense? I suppose as a workaround I could just make two separate views and add each one to the page as a block - I just thought that seemed a bit kludgy and that there had to be a better way.
Also, I've got another project on the horizon where I'll need to be able to show a long list of articles grouped by category, and as that one's got about 20 different categories, it really, really, really would not make sense to have to make each category a separate view. Thus my interest in trying to find some reasonable way of grouping view results even though the number of groups in the current project are small - because the number of groups in the other project, once I get to it, will not be.
Thank you for the response, by the way, and I'm sorry if I'm being a pest here.
Comment #4
rsevero commentedThis module isn't designed to solve this issue. The GroupBy in the modules name refers to the GROUP BY SQL query clause.
This module tries to implement the functionality that derives from mentioned clause.