R – Sorting grouped nodes by taxonothe term

drupalsortingtaxonomyviews

Ok, here's the problem:
I have a list of contacts, which i have created in views, that are grouped by taxonomy terms like so:

(term:) Staff:

(node:)  John Doe
         john@doe.com

(node:)  Jane Doe
         jane@doe.com

(term:) Management:

        Fred Doe
        fred@doe.com

        and so on...

As it is now, i have no idea what decides the order of the taxonomy terms (ie: why is the 'Staff' nodes coming before the 'Management nodes').

So what i need to do is to be able to sort the order of the terms, and also the order of the nodes in each 'category' (or what you would call it).

I have tried to sort the terms by weight, but the only thing that happens is that i get duplicated nodes output, and nothing happens with the order of the actual terms.

As for the order of the nodes, i was thinking that maybe a hidden CCK-field with some sort of weight, but i dont know. But the biggest problem is still the order of the categories.

If anyone has an answer to this it would be very helpful.

Thank you.


EDIT:

Strange, i tried that before i asked the question, but now it seems to work. However i still get duplicated nodes when i sort by taxonomy weight, for some reason. I really need to get rid of those. Heres how my view setup look, if its any help:

 
Fields: taxonomy=all terms (limited to one vocabulary) 
image attach content 

Sort criteria: Taxonomy weight:descending

Filters: Taxonomy term id(with depth) // to filter out what page it belongs Node type : contact node published : yes

dont know if that information helps at all

/Anders

Best Answer

The solution is simple, in views you can sort your result by the taxonomy term. You have 3 options as default.

From the views interface:

  • Term Taxonomy terms. Note that using this can cause duplicate nodes to appear in views; you must add filters to reduce the result set.
  • Term ID The taxonomy term ID
  • Taxonomy Weight The term weight field

The sorting in views, is located in the top right corner, and gives a wealth of options as to how you want to sort your results.

Edit:
Duplicates is a known problem with taxonomy terms. The problem is that if a node has two terms that fit it will be included once for each term. When you use the taxonomy term filter, you can reduce duplicates, which should fix your problem:

http://grab.by/16vw

Related Topic