Sorting doesn't work in view

chapo - June 19, 2008 - 12:24
Project:Content Taxonomy
Version:6.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Hi all,

I have a node type which is attached to a taxonomy (containing countries) through Content Taxonomy.
I build up a view displaying all nodes of this type, and I would like to be able to display only the one relative to a country (a term in my taxonomy). So I exposed the filter Content Taxonomy. However, nothing happens when I select a country and the full list of nodes remains. I also have another exposed filter (Node reference) which works perfectly.

Does anybody already add this kind of problem and could help me solving it ? (I could of course forget Content Taxonomy and directly attach my taxonomy terms to my node type, but this create other site specific problems)

Thanks,

#1

a.horoshavin - January 20, 2009 - 02:21
Version:5.x-1.x-dev» 6.x-1.x-dev

subscribe (6.x)

#2

philsward - January 24, 2009 - 00:34

I too am wanting to do some sorting based off of my Content Taxonomy views fields. I have my views style set to 'Table' but I don't even have an option for making my CT fields sortable... This would be a nice feature to have.

#3

fractile81 - February 12, 2009 - 18:43

The ability to do so is there, it's just not immediately obvious.

Although creating a content taxonomy field and throwing it into a table produces a column of term names, Views only sees the data as a bunch of tids. Because of this, allowing the sorting on that column would produce some unintended results.

Instead, you need to create a relationship. Once you've created your Content Taxonomy field, go to your View and add a relationship. Under the "Content" selections, pick the Content Taxonomy field you want sortable. Save that, and now you need to create a new field. Select "Taxonomy: Term" as your field and continue. In the new options and in the "Relationship" dropdown, select the relationship that you just created, make any other changes you'd like, then click the "Update" button.

At this point, you should be able to click your "Style: Table" gear and be able to sort by term name. Just remember to save the changes to the View itself! =)

#4

philsward - February 12, 2009 - 19:48

It's kind of funny that you should mention using the relationships for sorting. I did some research on relationships, found this video: http://drewish.com/node/127 and realized that relationships is the way to go for sorting content taxonomy terms (and a slew of other things) :)

Thx for the in-depth reply on how to sort using relationships! I was able to get mine to work perfectly doing the suggested method.

#5

rconstantine - June 29, 2009 - 20:10

I'd say this was fixed thanks to #3 though it should be added to the docs.

I also have a question to add...

Does it make sense to somehow add grouping as an option when using the sorting in #3? Use case: given a vocabulary 2-deep with building/department relationships, I'd like to group the terms on a given node so that just one row per node is displayed, but I still want to sort on that row. I would expect the building (the first layer of term) to be first, alphabetically, then the department. In other words, sort on the concatenation of terms where each layer of term adds to the concatenation.

Is this possible now? If not, would it be hard to do? If my customer really wants this, I don't mind making the patch myself. I'm just hoping for a rough idea on how hard this would be from any of you out there who are familiar with this module's code. Perhaps it isn't even possible due to some kind of technical restriction that you know about.

#6

chaloalvarezj - August 21, 2009 - 06:52

subscribing so as to not forget about this!

#7

alex.k - October 2, 2009 - 09:48

Great tip in #3, thank you.

For those interested, you can extend this a little bit to sort not alphabetically, but by term weight. That'll allow you to reorder terms at admin/content/taxonomy and have the sorting respect that order. Useful for sequences like "low, medium, high".

Add the relationship, and per instructions above, add the "Taxonomy: Term" field. Also, add the "Taxonomy: Weight" field. Configure the Term field as you need it, and check "Exclude from display".

On the Weight field, check "Rewrite the output of this field", and enter the token for the term field you have above. The naming convention isn't very nice in that it's hard to tell which field is the one you need. For me they looked like "[name_1]", "[name_2]", etc.

Now the weight field is what Views is showing and doing sorting on, but thanks to the rewrite the Term field is actually displayed.

#8

drewish - October 7, 2009 - 18:43
Status:active» fixed

i guess it's safe to close this.

#9

System Message - October 21, 2009 - 18:50
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.