Sorting on Taxonomy
remtheory - June 18, 2007 - 14:24
| Project: | CCK Taxonomy Fields |
| Version: | 5.x-1.1 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
When I create a view, the CCK taxonomy fields I created don't show up in Sort Criteria, only in Fields. Is there are reason for this? It would be great to be able to sort by separate taxonomies!

#1
I'm not sure how to implement this and need some help from the CCK/Views experts.
#2
#3
Robert,
I'm certainly not a views expert, and the following stuff may not even apply here.
But I've worked some dynamic views sorting functionality and have a few building blocks that may help glue something together.
First check out, Adding Sort via Argument Handler which is gives a PHP snippet for the Views Argument Handling Code, which would probably be implemented programatically.
if ($args[1]== "desc") {$view->sort[0]['vid'] = 4;
$view->sort[0]['position'] = 0;
$view->sort[0]['field'] = 'node.nid';
$view->sort[0]['sortorder'] = 'DESC';
$view->sort[0]['options'] = '';
$view->sort[0]['tablename'] = '';
$view->sort[0]['id'] = 'node.nid';
}
return $args;
The vid would also be abstracted, and there would be different sorting behavior. But the idea would be to add an extra URL argument that would give a specific sorting behavior. The simplest thing would be to theme a direct link to that sorting URL
Another option that I'm exploring is creating a drop down widget that makes an AJAX-POST call when it is selected. This could provide a UI that is placed in the header that is able to call the URL with the sorted behavior from a drop-down menu. The code there was modified from this post.
Anyway, not sure if that helped, but hopefully spurred some ideas.
#4
Thanks Kent. The problem I ran into was not knowing how exactly to join the CCK generated table which contains a numeric tid with the term_data table which has the text information and then sort on that text information. CCK handles parts of the Views integration on its own and leaves parts up to the module. I actually wrote a join to the term_data table and wrote a sort description that made sense to me, but it didn't want to work.
#5
I see. Well maybe posting the broken JOIN code here would help if you don't get the answer from elsewhere.
#6
And not just sort, but links to the taxonomy nodes would be nice, too, like Views does with the default taxonomy module fields... And why does Views show the CCK Taxonomy fields in a vertical list vs. the default taxonomy module fields in a horizontal list? Control over the output styling would be nice...sortable, and as links. I am trying to do a comparison table (very crude and limited Drupal version) and need every cell sortable and clickable.
#7
This is the only thing holding me back from making the switch as well. The Ajax sort provided by the core module is crucial.