i've just been learning views' rather complex structure since yesterday, but hope this might either be corrected by those with more experience, or is useful as is to other newbies.

several users have in various contexts requested ability to group taxonomy term searches by vocabulary. one simple, quick hack to achieve this is outlined below. note that this is limited in applicability: it only uses vocabulary ID, not weight or name. also, of course, nodes that have multiple terms will be displayed repeatedly for each term, unless further filtered.

in essence, add a sort handler for the term_data.vid field.

this could be done in a separate module, or another less kludgy way. but hacking views: edit views/modules/taxonomy.views.inc, and change the section describing term_data table, Term vocabulary field to the following:

  // Term vocabulary
  $data['term_data']['vid'] = array(
    'title' => t('Vocabulary'),
    'help' => t('Filter or sort the results of "Taxonomy: Term" by a particular vocabulary.'),
    'filter' => array(
      'handler' => 'views_handler_filter_vocabulary_vid',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  ); 

this just adds the handler at the bottom and revises the help.

now you will be able to add a sort for vocabulary id.

CommentFileSizeAuthor
#2 views_sort_by_vocab_id.patch720 bytesbrush

Comments

dawehner’s picture

Status: Needs review » Needs work

Even i cannot think of any use case, this could be sure part of views.

Do you want to write a patch?

brush’s picture

Status: Needs work » Needs review
StatusFileSize
new720 bytes

ok, but i think a more comprehensive solution is the patch at the end of [#150896: Sort on Taxonomy: Terms for [your vocabulary]]. still, fwiw, patch attached.

merlinofchaos’s picture

Status: Needs review » Fixed

I moved this to {vocabulary} so it would be universal. Also added a sort on vocabulary name, since it's actually a more interesting sort (usually) than vocabulary id, I would think.

merlinofchaos’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev

I only committed this to the 3.x branches, btw.

dawehner’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Fixed » Patch (to be ported)

Update status.

merlinofchaos’s picture

Status: Patch (to be ported) » Fixed

I got it into D7 as well as D6. I was merely commenting that I did not commit it to Views 2. =)

Status: Fixed » Closed (fixed)

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