Using the 1.0-rc2 version of Content Taxonomy we discovered that the one thing we really wanted to do with views, sort by content taxonomy fields, we couldn't do. This was very easy to add, and so far works exactly as it should. We also added argument support in a simple way by tid, also works very well.

Comments

artbrock’s picture

Title: Views Sorting and Arguments Support » Patch to support Sorting and Arguments in Views
Assigned: artbrock » Unassigned
Category: feature » bug

Renamed issue to make it clearer that I'm providing a patch.

jim kirkpatrick’s picture

Status: Needs review » Reviewed & tested by the community

Works very well for me, thank you... Had to re-save the view before it appeared, but that could just be a caching issue. Much better than trying to add a relationship and then stop a load of duplicates...

Thanks again, great!

YK85’s picture

+1 subscribing

chalee’s picture

This patch is not working for me. I'm using Content Taxonomy 6.x-1.0-rc2, Views 6.x-2.6, CCK 6.x-2.5. I copied the patch file into the content_taxonomy module folder and applied the patch to using command:

patch content_taxonomy.module content_taxonomy-6.x-1.0-rc2-views.patch

I checked the content_taxonomy.module file and it has the two lines in the patch file added.
I was now able to see the content taxonomy field when I click add sort field (+) which I was not able to do before. I added the field and chose ascending sort order. However when I save and open my view the entries are not sorted properly. What surprises me is that when I change the sort order to descending, the order of the view entries are reversed, which means the sort field is having some effect but it's just not sorting properly. Can someone assist me. Did I apply the patch correctly? Do I have to do something else for this patch to work? The other method of using relationship is also not working as it is producing duplicates. Thanks in advance for the help.

xjm’s picture

Marked #536918: How car I sort my view ? as duplicate of this issue.

magnus’s picture

Version: 6.x-1.0-rc2 » 6.x-1.x-dev
StatusFileSize
new663 bytes

Thanks!
This works really well. I attached a patch for dev in case anyone has problem to apply the patch.

ru.meta’s picture

StatusFileSize
new26.52 KB

I've applied patch for "dev" version and nothing is changed. May be I miss something?
I'm trying to sort by taxonomy content field in table view.

Thanks

magnus’s picture

Check under "Sorting" above "Filters". Not in style.

garyabbott’s picture

I've applied the patch with: drupal 6.16, cck 6x-2.6, views 6x-2.10 and CT 6.x-1.0-rc2 and although the fields show up as arguments, they do not seem to pass anything in. The SQL indicates a value of 0 for the argument.

edit1:
It may have something to do with text versus integer. If I have a number like 2007 as the argument, that gets passed to the SQL as 2007. If I have in a text string like blue, that gets passed as 0.

edit2:
OK, I see now that it is expecting the taxonomy id number (which I guess you said, but I did not absorb in the first post) not the value/name. Not sure yet how to use this as I actually generate a URL (with taxonomy argument for another view call) from a content taxonomy field in the view, which of course has the name, not the id number. Sigh.

edit3:
Back in business. In the argument setup you can turn on taxonomy validator and the option to convert term name to term id.

gagarine’s picture

I try the patch it work perfectly for me. Thanks

jyg’s picture

It seems this applies only to the Sort criteria, not to the Basic Settings' Style of "Table".

If you want to sort taxonomy in a table, use content_taxonomy and follow this: http://drupal.org/node/272424#comment-1254224

mstrelan’s picture

The sorting seems to order by term id, not term name. To get around this I have created a relationship for my Content Taxonomy Field. Then in sorting I sort by Taxonomy Term Name, using the aforementioned relationship.

mrgoltra’s picture

subscribing

minff’s picture

If you want to sort by term name in table-type views, then create a relationship, as described in http://drupal.org/node/272424#comment-1254224 (and referred to in comment #11).
To take it shortly together: (1) add the CCK field that you want to use for sorting as a relationship; then (2) add a taxonomy term as a new field and tie it to the relationship; and then (3) check "sortable" in the style options of the table-type.
Worked for me!

emediquei’s picture

The patch worked for me, thanks!

Still, it would be nice if it also supported sorting in the table style. I can't use a relationship since I'm using editablefields.

mastervissie’s picture

Any plans to apply the patch?