Hello,
I have a cck content type with some fields (title, author, ...), one of which is a required term from a taxonomy vocabulary (topic). Now I want to display a short list of links to such nodes (i.e. show just title and author, which links to the node itself), and have them grouped by the terms from this taxonomy vocabulary (i.e. by topic).
So I have setup a view which display the title and author fields, while it has the topic as a hidden field. As a basic setting I have chosen the Table style, where I select topic as the grouping field, with ascending ordering...
Now it shows a table for each topic, but the topics itself are not in the right order (that is, they are not in the order of the vocabulary itself). What am I doing wrong? Or: how can I enforce the taxonomy ordering (actually, alphabetically would also do just fine) for the "grouping field"?
Thanks,
Franky
Comments
For those interested, the
For those interested, the view is at:
http://www.win.ua.ac.be/studenten/bachelorwerkjes/overzicht
The term_data for the vocabulary is:
Update: Setting this as the "grouping field" and sorting the title alphabetically, results in the groups being sorted according to the first title that appears in each group.
More generally, you can get an order like this:
Group C
-- Item A
-- Item F
Group A
-- Item B
-- Item E
Group B
-- Item C
-- Item D
while the order I am looking for is:
Group A
-- Item B
-- Item E
Group B
-- Item C
-- Item D
Group C
-- Item A
-- Item F
That is, I want to sort the terms of the group field alphabetically, and then for each group the items alphabetically as well.
Any ideas?
Same problem here.
Same problem here.
i got the same problem as
i got the same problem as well
i got loads of nodes and i group them by vocabulary term.
trying to sort them groups by term weight and it just doesn't work.
any advice would be highly appreciated.
Did anyone figure out how to
Did anyone figure out how to do this? I'm trying to do the same thing.
i dont think so. i still
i dont think so. i still facing this problem.
Yep, also still having this
Yep, also still having this problem
In the Sort criteria add
In the
Sort criteriaaddTaxonomy: WeightHope this helps!
Same problem here
Same problem here too,
subscribing
Another Instance: List item groups won't sort by weight
I am having essentially the same issue:
I have a view display which returns a list of nodes, grouped in HTML Lists by a taxonomy term.
The view display has "Taxonomy: Weight asc" followed by "Node: Title asc" in the Sort Criteria.
The view returns grouped lists of nodes with the taxonomy term as a header, but the groupings are not sorted by the Weight of the taxonomy term. Instead the groupings are sorted alphabetically by the Title of the first node in their list.
It appears that the Sort Criteria is only being applied to the members of each grouping, not the term under which the members are grouped.
How can I get the Sort Criteria to apply to the terms that the lists are grouped by instead of just the list members themselves?
Thanks!
~ Kevin
This is an issue in Views
This appears to be covered by this issue in the Views queue. As of yet it doesn't seem to have anyone working on it.
http://drupal.org/node/773000
~ K
what works for me
Hello again,
I think I've found a way to get the sorting done properly, that is, by ordering the grouping fields according to it's (taxonomy) weight and only then sorted alphabetically by title inside each of these groups...
To do this, I have a taxonomy vocabulary setup for "Group" with terms A, B, C with associated weights 0, 1, 2.
In my content type, I have a "Group" CCK field of type Content Taxonomy Fields which uses the "Group" vocabulary.
The associated view contains "Content: Group" as well as "Node: Title", and uses "Content: Group" as its Grouping field. Here, I unselected "Override normal sorting if click sorting is used".
Next, I added and require a Relationship for "Content: Group".
To get the sorting to work, I added the "Taxonomy: Weight" Sort criteria with Relationship "Group term" and Sort order "Ascending". Finally, I added "Node: Title" as the second Sort criteria also with Sort order "Ascending".
Now, the view shows the "Group" terms in the appropriate order (defined by the weight), and inside each group, the items are listed alphabetically by Node Title. Changes to either the weight of the "Group" terms or the "Node: Title" show up appropriately...
Yet, I'm not really sure whether this has other side effects, and maybe I'm abusing the Relationship system, but it does work. So if anyone (listed above) could check this and let us know whether it does indeed rectify the situation, that would be greatly appreciated.
Update: I forgot to mention that I also used patch #2 from http://drupal.org/node/1056170 to be able to use "Taxonomy: weight" in Sort criteria...
-- Regards,
Franky
Drupal 7 Solution
On D.7, I solved it this way:
1. Relationships > add > "Content: [vocabulary]"
2. Sort criteria > add > "Taxonomy term: Name" > Choose "Relationship" as the one just added
Yes!
With Drupal 7 It worked for me.
Without any patch and without the Views Group By module.
Thanks!
Awesome Sauce!
THANK YOU! This worked perfectly!
worked for me.
Payamspot's instructions worked for me
Although, in my case, I was using a Table, and I had to make sure the sort column on the table was set to none. It also worked, FYI, with three two groupings of taxonomy, and a third taxonomy sort inside that.
Election (grouping)
State (grouping)
Race (just a sort)
This Works
Worked like a charm. Thanks!
I had to set Relationships to
I had to set Relationships to:
"Content: Taxonomy terms on node"
and it worked perfect.
Thanks!
Worked great. Thanks
Worked great. Thanks
Worked perfectly.
Thanks. The above solution worked perfectly.
bingo
Adding the relationships and setting it for the weight sort criteria item was all I had to do. Thanks Franky!!
Just to confirm that all you
Just to confirm that all you meed to do is:
1. Add a relationship Taxonomy:Node
2. Add Sort criteria Taxonomy Weight and specify relationship. This will sort grouped fields.
3. Add Sort creteria Node:Title (or any other member of grouping field that you use) and specify a relationship. This will sort items within groups.
Tested on Views version = "6.x-3.x-dev" from 2011-03-15 an no patching is required.
Founder, Software Engineer | www.drevops.com
Also worked
I had a similar requirement for sorting and grouping on taxonomy term, and in the end, the following configuration worked (Thanks for all the suggestions above).
I am using Views 6x-2.12, and I have Views GroupBy 6.x-1.0-rc2
Background:
I want to organize publications. Each publication has up to three taxonomy terms, including a [country] taxonomy. For every country there is generally an older publication and the latest publication.
I wanted to list the reports first by country, then the newest first. E.g.
Belgium
2011 Latest report
2000 Old report
Botswana
2011 Latest report
2002 Old report
After much trial and error, the following worked:
Created a Node view / type: page:
Relationships
Taxonomy: Related terms (There were two Related terms options and I choose the second one - "relate nodes to taxonomy terms...")
Require this relationship (No/unticked)
Vocabularies:
[Countries] (the "group-by" term)
Name 'term'
Fields
Content: year (this was the secondary sort criteria in my case)
Node: Title
Taxonomy: (term) Taxonomy term, Exclude from display/label=blank - (i.e. using the 'term' relationship)
Sort criteria
1st Sort:
Taxonomy Term
Use the relationship 'term'
2nd Sort:
Content year
Style: HTML List
Grouping field (term) Taxonomy: Term: unordered list - (i.e. using the 'term' relationship)
Arguments
Taxonomy Term ID
Title: %1
Argument type (term name/synonym converted to term ID),
transform dashes in URL to spaces in term name arguements - yes
Validator: Taxonomy term
Vocabularies [publication]
Reduce Duplicates (yes)
Filters
Node: Published Yes
Node: Type = Publication
Excellent!
Thank you DropInTheOcean, this worked 100% and you are formally awesome.
Much obliged.
Looking for a solution...
For those of us that can't use grouping (or the other particulars of the above-referenced solutions) I'd like to see this fixed. I have even stooped to putting alphabetical prefixes in my term names, thinking that sorting alphabetically would work as a last resort. But somehow even that doesn't work. I have only one sort field - taxonomy name - but it is ordering by the date I added the term, not the alphabetical position of it's name.
Also, at least in D7, if you re-sort the terms alphabetically, and then click 'save' again later for any reason, the field order discombobulates back into the order it was before sorting alphabetically.
In D7 with the latest everything, it seems taxonomies as a sort field in views - and sorting in general - is somewhat fudged?
D6.25, Views 6.x-2.16 I have
D6.25, Views 6.x-2.16
I have control of sorting for my field groups using this module:
http://drupal.org/project/views_groupby
The module is built for deeper reasons but along the way it seems to give you sort control (via the SQL query) before the regular Views styled list grouping.
FYI, it took some tinkering in the Fields area but eventually was able to get it right. I had to read the module basic example in the documentation a few times.
Also... funny thing... the preview of my View and the View in my page node are reversed. So basically you cannot trust the Views preview output when using this module. I think maybe the query being generated by Views preview and Views in the page node may be slightly different.
Just a quick thought
Isnt it possible to setup a relationship to the term you want to order on? Then use this relationship to set the name / content title of the related term as sort order. Worked for me.
I was having the same issues
I was having the same issues as many of the people here.
Views 3, D7x
I tried several different types of relationships and sort criteria, but the view grouping was always sorted by date the taxonomy term was added.
For me it was because under Format: settings i had originally set a default sort order (desc/asc) on the Taxonomy term which was overriding my relationship/sort order combo.
For 7.x in case it helps someone else
I fixed this for myself in D7 by doing the following in the View:
1. Add a Relationship to the field that contains the term_reference (mine was "Content: Category")
2. Add a Sort Criteria to "Taxonomy term: Weight" (make sure the Relationship specified is correct)
3. Add a Sort Criteria to "Taxonomy term: Name"
4 Add a Sort Criteria to "Content: Title"
-cdmo
parent child order
Thanks for all the tips on this thread…
I wanted my view to be in top-to-bottom order of a nested taxonomy (mine was just two levels, parent & child).
I had to add a relationship for the taxonomy term first.
Then add a second relationship for the "Term Parent" using the original term relationship as the relationship for the parent.
Next I had to add two levels of sort criteria:
1) (Parent) Taxonomy: Term (weight, asc) [this must be first]
2) (term from field_category) Taxonomy: Term (weight, asc)
So now it sorts the top level first then the subsequent lists of children and so it all ends up looking like the proper order of the term list.
Hope this helps someone like all the other comments here helped me. :)
This did the trick
Thank you! This worked perfectly for me!
Sorting Grouped Fields by taxonomy term
I had this same problem and was stuck for a while, but through comments in this thread I was able to find a non-code solution that was very flexible.
I can now sort grouped fields in a views table by the taxonomy grouping in whatever order I want.
I had a taxonomy term called Subject Area that I was using to group node titles of different courses in a Course Guide. Each subject area needed to be sorted alphabetically with the node titles in each subject also being sorted alpha.
Here's how I did it:
1. Create a Relationship using Content: Subject Area (the term reference field on the course node)
2. Create a sort of Taxonomy Term: Weight (Ascending) using the relationship above and made sure that this was the first parameter in the sort settings (!!! important !!!)
3. Created a sort by Content: Title (ascending) as the second sort parameter.
4. Added the Content: Subject Area field to the table, but hide it from the view.
5. In the table settings, set Grouping Field to Content: Subject Area
In order to control the order, simply reposition the listed terms in the Subject Area taxonomy vocabulary to the order you want the groupings appear in the view.
Hello from 2020
This still works in Drupal 8+.