Comments

anrikun’s picture

Title: Provide: sort based on vocabulary weight » Sorting: order by vocabulary weight
anrikun’s picture

Assigned: Unassigned » anrikun
Status: Active » Needs review
StatusFileSize
new634 bytes

Actually, adding this was quick.
Please review the attached patch. It adds the missing "Vocabulary weight" (field and sort).

iamjon’s picture

kbaringer’s picture

Thanks for the suggestion, but unfortunately the patch doesn't solve the problem with sorting by taxonomy term weight. What it does is add an option to sort by vocabulary weight (which is also a worthwhile improvement!).

The thread at http://drupal.org/node/773000 deals with getting the taxonomy term weight to be recognized when the query results are grouped by taxonomy term in the HTML List style. This way the groups that are created for each taxonomy term will be sorted on the page by the weight of the term ($title in the item_list class as written by views-view-list.tpl.php).

Suggestions on that topic are still welcome!
~K

anrikun’s picture

Have you tried to sort by vocabulary weight (you need the patch for that), then by term weight?
It works for me.

kbaringer’s picture

@anrikun, I did try sorting by vocabulary weight after applying the patch, but it doesn't solve the problem for the site I'm modifying because they are already filtering the view using vocabulary. All of the nodes that are returned have the same vocabulary, so sorting by that field doesn't do anything.

The only thing being displayed by the view are node titles, but they are grouped (in HTML lists) by taxonomy term. The client would like the groups to be sorted within the view based on the weight of the taxonomy term.

Comment #1 in this thread http://drupal.org/node/773000 states "You would have to override the argument handler of terms". I'm willing to give this a try but since I'm still learning my way around the Drupal architecture I'd love to have a mentor. Anyone willing to help me out?
~ K

anrikun’s picture

Could you post a screenshot of your view's edit form (admin/build/views/edit/VIEW_NAME)?

jelo’s picture

sub

fbackelj’s picture

Hello, using this patch I was able to get a two level sorted list, first by Grouping field using the patch from #2 here, and then by Node title. The details are at http://drupal.org/node/921498.

Thanks for this patch.

anrikun’s picture

Thanks.
Can someone else confirm that the patch works? This could then be marked as RTBC.

Alphabool’s picture

anrikun, I don't mean to hijack this thread, but I want to know whether this patch would make it possible to specify the vocabulary a term comes from when specifying a taxonomy term field in Views. That is currently what I am struggling with.

anrikun’s picture

@Alphabool: You should try the "vocabulary" filter that already exists in Views.
The patch here only provides the missing "sort by vocabulary weight".
Please, if you need further help about this, post it as a separate support request.

tannerg’s picture

Is this patch scheduled to make it into the main branch of this module?

anrikun’s picture

It has to be marked as RTBC first (I won't do it myself as I'm the one who posted the patch).

dawehner’s picture

In general feature requests are currently only applied to 6.x-3.x.
6.x-2.x is in a bug fix only status. But this clearly can't break something

bolecha’s picture

Where to apply the patch#2?
I can't find modules/taxonomy.views.inc.

Is this file in the views module?

dawehner’s picture

Is this file in the views module?
yes it is

bolecha’s picture

Thank you.
I found the file.

pol’s picture

Hello,

I made the same patch for myself this morning and I was about to make a new issue when I found this thread.

I've updated the patch and added the taxonomy vocabulary weight as an argument and also for the term weight.
Maybe it will be useful to someone one day, who knows ;-)

This patch is for views 7.x-3.x but I'm pretty sur that it can be almost the same for 6.x-2.x and 6.x-3.x, if you need them, I can provide them.

pol’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
tim.plunkett’s picture

Triggering the testbot.

Status: Needs review » Needs work
pol’s picture

I'll provide a new patch very soon, probably today.

pol’s picture

Status: Needs work » Needs review
StatusFileSize
new1.52 KB

Updated patch.

johnpitcairn’s picture

Patch at #24 works for me. I have a multi-value taxonomy field, and I'm able to add a relationship "Content: taxonomy terms on node", a field "Taxonomy: term name" using that relationship, group the display by the taxonomy term name field, then sort the groups by term weight using the relationship, and by node title within each group. Sweet.

tim.plunkett’s picture

Status: Needs review » Needs work
+++ b/modules/taxonomy.views.incundefined
@@ -90,6 +90,24 @@ function taxonomy_views_data() {
+    'title' => t('Weight'), // The item it appears as on the UI,

I don't think this inline comment is necessary. Perhaps it was from the examples/documentation? Let's remove it.

Otherwise, looks great.

pol’s picture

Here's the modified version of the patch.

I removed the inline comment as suggested by @tim.plunkett.

pol’s picture

Status: Needs work » Needs review
tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me!

dawehner’s picture

Status: Reviewed & tested by the community » Needs work

      'weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The weight of this vocabulary in relation to other vocabularies.',
      ),

This is the schema definition in taxonomy.install, so it's technical a number.

Based on this, the handler types should be a bit different:

+++ b/modules/taxonomy.views.incundefined
@@ -86,6 +86,24 @@ function taxonomy_views_data() {
+      'handler' => 'views_handler_field',

views_handler_field_numeric

+++ b/modules/taxonomy.views.incundefined
@@ -86,6 +86,24 @@ function taxonomy_views_data() {
+      'handler' => 'views_handler_argument',

views_handler_argument_numeric

+++ b/modules/taxonomy.views.incundefined
@@ -86,6 +86,24 @@ function taxonomy_views_data() {
+      'handler' => 'views_handler_filter_string',

views_handler_filter_numeric

tim.plunkett’s picture

Assigned: anrikun » dawehner
Status: Needs work » Needs review
StatusFileSize
new1.36 KB

Rerolled, included patch credit for Pol and a commit message.

FranCarstens’s picture

The timing on this is perfect. I so need it today! Btw. it works for me. :D

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

This looks perfect so far.

dawehner’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the patch!

Committed this one to 7.x-3.x and 8.x-3.x

Status: Fixed » Closed (fixed)

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