Views is coming along awesomely!

I have a table view that has a few "Taxonomy: All Terms" fields in it (needed because I want some of the table's columns to represent only one taxonomy each). Everything shows up on the view as expected, but I cannot sort by these "Taxonomy: All Terms" fields.

My request is that these "Taxonomy: All Terms" fields be sortable by the field's first term in a table view.

Thanks for all of the great work on this module!

Comments

merlinofchaos’s picture

Status: Active » Closed (won't fix)

Unfortunately, this is not possible because the terms are not actually part of the query. They are pulled up from a second query, and there is no way to accomplish what you ask.

matt_paz’s picture

content_taxonomy should provide a sideways approach to dealing with this issue when it is ported to 6 ... it allows you to store a snap shot of the term name in a text field (in addition to storing in a proper term_node relationship) which should be sortable in views ... I think that would address the needs of those looking to sort on a taxonomy term. The denormalized snapshot can come in handy in other areas too.

merlinofchaos’s picture

Denormalized data is fun! That sounds like a great solution.

matt_paz’s picture

Okay, so should revise my earlier recommendation regarding content taxonomy. Seems it is intended to completely replace taxonomy rather than augment it, so I think we've decided it may be more trouble than it is worth, but still remain a little undecided. As a result, I've been working towards a more primitive solution. I've added cck text fields for taxonomy items that I want to denormalize for use in views. Then I use hook_nodeapi to update the fields I want and hook_taxonomy to update all references to those fields should a taxonomy item change. Seems to be working pretty well so far, but augmenting normalized data w/ denormalized data can prove "interesting" ... I'll probably add a cron job to help w/ additional clean up just in case. If anyone has additional thoughts or commentary, I'd be interested.

Thanks!

Matt

nimrod98’s picture

Instead of sorting it, perhaps you can choose to filter by taxonomy terms and expose it. Just a thought =)

vthirteen’s picture

for those who will choose to sort through Content Taxonomy, a few instructions to make the field sortable (using a relationship in views):
http://drupal.org/node/272424#comment-1254224

bartezz’s picture

Without smilies I'm not sure how to read your post Merlin, but I take it it was meant as an sarcastic post.

I've tried finding out why you don't think it's a good solution but I can't really see why.
We would like to sort a table by a taxonomy term. I know this isn't possible due to the complexity of the query and such (read this post too).

But Content Taxonomy as described in this post is the only possible solution I have found so far to sort on taxonomy terms.
Could you tell me why this isn't a good solution, and if there is a possible other solution through other ways/modules?

Thank you

xenophyle’s picture

I hope I'm not breaking some rule by responding to a post that is not only old, but "won't fix"...
But I am curious: would it be possible to do this using JavaScript, i.e. clicking on table headers, rather than by server request?

merlinofchaos’s picture

It would be possible but it doesn't exist as a simple tool you can plug in. But there is javascript out there that can do it pretty easily so it wouldn't take too much to do it just on your site.

bartezz’s picture

The best Jquery/Javascript table sorter I know of: http://tablesorter.com/docs/

Cheers

eiland’s picture

...but that wont work of course if your table is longer than one page :(
Filers do work but it stays less elegant.

jaapjan’s picture

StatusFileSize
new97.55 KB

I know this issue is closed, but maybe this will help others fix this problem.. You can fix this by using the module views_php: http://drupal.org/project/views_php It isn't necessary to install content_taxonomy. Even paging will work. I use Views 6.x.3.. but it will probably work for Views 6.x.2 too.. Just setup the view by following these steps:

1) Install views_php
2) Edit the view and make a relationship: "Taxonomy: terms on node" and select the desired vocabulary name.
3) Add a field: Taxonomy term and select the newly created relationship from step 2. If you want to you can decide not to display this field..
4) Add a field: Global -> PHP and return the value from the field created in step 3 in "value code". Be sure to follow the steps in 5 and 6 before saving this field.
5) Enable click sort by selecting "sort alphabetically". Return the value from the field created in step 3.
6) Output the code by printing the value from the field created in step 3. Save the field.
7) Enable sorting in this table column by editing the table settings.

See the attached screenshot for setting up the php field.