简体   繁体   English

Drupal视图-在不同的词汇页面上时,分类术语权重的排序顺序?

[英]Drupal Views - Sort order of taxonomy term weight, when on a different vocabulary page?

My nodes that are categorised by 2 taxonomy vocabularies. 按2个分类词汇分类的我的节点。 Both vocabularies have taxonomy pages that list all the tagged nodes. 这两个词汇都有分类法页面,其中列出了所有标记的节点。 Every node is has 1 tag from each vocabulary. 每个节点的每个词汇表都有1个标签。

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. 对于我的主要词汇im的分类页面,使用CCK整数字段来控制顺序。 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. 对于我的辅助词汇的分类页面,我希望顺序是主要词汇的术语权重,然后是CCK整数字段顺序。

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. 我想我可以用2个排序顺序来做到这一点,第一个是第一词汇中的术语权重,第二是CCK字段顺序。 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 谢谢

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: 如果要处理术语视图,没有简单的方法,建议您在这样的自定义模块中使用hook_views_query_alter:

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. 如果您可以负担得起空条款,我的建议是使用内容分类模块并创建节点视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM