0

I am trying to get a list of distinct taxonomy terms in drupal using views2. It seems it shouldnt be that big of a problem, however when i select the taxonomy:all terms, and select what vocabulary to limit to i get duplicates. The "distinct" option in drupal does nothing, and i cant find anything else that groups it together. If anyone knows anything that would be great.

Thank you.

/Anders

4

2 回答 2

1

在分类术语的情况下,views2 将 distinct 子句应用于术语 id,这在您的情况下相当无用。所以 afaik 如果不通过自定义编码操作视图,就无法在 view2 中做你想做的事情。

因此,您可能需要查看hook_views_query_alter()一个选项来操作视图使用的查询。或者,您可以通过代码执行视图,并在执行视图后过滤 $view->result 中的结果集。

但是,根据您需要列表的目的,与仅忽略此任务的视图模块并直接在自定义模块的代码中执行查询相比,这些方法可能有点矫枉过正。

于 2009-09-29T18:09:55.237 回答
0

The problem you have having is what you actually are doing is to get all the taxonomies that match on every node on your site. A quick hack would be to create a node (doesn't need to actually be published) that contains all of the taxonomy terms, then you could limit the nodes to only that node and you would get a list of all taxonomy terms you want.

Else I would go for one of the options that Henrik Opel suggested, personally I would just make a little custom module for this, and make the queries myself.

Views is a very powerful module, but in some cases, it's actually a lot easier and faster to just do the queries yourself. Especially when the display is not so complicated. You could even use the templates that views has to render your data, if you don't want/need to create your own.

于 2009-09-29T19:53:15.993 回答