0
votes

My nodes that are categorised by 2 taxonomy vocabularies. Both vocabularies have taxonomy pages that list all the tagged nodes. Every node is has 1 tag from each vocabulary.

Im using a views override to control taxonomy pages. For my taxonomy pages for my main vocabulary im using a CCK integer field to control the order. This is straightforward and working fine.

For taxonomy pages for my secondary vocabulary, I want the order to be the the term weight of the main vocabulary, and then the CCK integer field order.

I think I can do this with 2 sort orders, the first being the term weight from the 1st vocabulary, and the 2nd being the CCK field order. The issue that im having however is if I add the term or term weight as a sort criteria to my view, I cant specify the primary vocabulary, so it uses the the taxonomy term that the page is on. This means on the main taxonomy pages it works fine, but it doesn't work on the 2nd taxonomy pages.

I dont know if it will help, but below is an example order:

1st Vocab
-TERM1
--NodeA
--NodeB
-TERM2
--NodeC
--NodeD

2nd Vocab
-TERM3
--NodeA
--NodeC
-TERM4
--NodeB
--NodeD

How can I solve this? Thanks

1

1 Answers

1
votes

If you're dealing with a term view there's no easy way, I suggest you to use hook_views_query_alter in a custom module like this:

function YOURMODULE_views_query_alter(&$view, &$query) {
  if ('YOUR VIEW NAME' == $view->name) {
    $query->add_orderby(<TABLE ALIAS>, <TABLE FIELD>, 'ASC');
  }
}  

if you can afford filter out empty terms my advice is to use content taxonomy module and create a node view instead.