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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | views_sort_by_vocab_id.patch | 720 bytes | brush |
Comments
Comment #1
dawehnerEven i cannot think of any use case, this could be sure part of views.
Do you want to write a patch?
Comment #2
brush commentedok, 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.
Comment #3
merlinofchaos commentedI 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.
Comment #4
merlinofchaos commentedI only committed this to the 3.x branches, btw.
Comment #5
dawehnerUpdate status.
Comment #6
merlinofchaos commentedI got it into D7 as well as D6. I was merely commenting that I did not commit it to Views 2. =)