简体   繁体   English

Drupal:视图分组问题

[英]Drupal: Views Grouping Issue

With CCK, I've added a field to the basic "Page" node type called "Resource Type". 使用CCK,我向基本的“页面”节点类型(称为“资源类型”)添加了一个字段。 There are four possible resource types to choose from, in a dropdown, "Training, News, Research, Tools". 在下拉菜单“培训,新闻,研究,工具”中,有四种可能的资源类型可供选择。

I've created a view that should group the nodes by their resource type. 我创建了一个视图,该视图应按节点的资源类型对其进行分组。 I've created 8 nodes, 6 of which are of type "Training", 1 is of type "Tools" and 1 is of type "News". 我创建了8个节点,其中6个属于“培训”类型,1个属于“工具”类型,1个属于“新闻”类型。 Drupal is outputting the following: Drupal输出以下内容:

Training
- Training Node 1
- News Node 1
- Tools Node 1
- Training Node 2
- Training Node 3

Tools
- Training Node 4

News
- Training Node 5

Research
- Training Node 6

When I tested with only 1 node per resource type, it displays as expected: 当我测试每种资源类型只有1个节点时,它会按预期显示:

Training
- Training Node 1

Tools
- Tools Node 1

News
- News Node 1

I saw the other posting where the Devel module can screw up the output, but I'm seeing the above while the user is logged out (and therefore Devel is disabled for anonymous users). 我看到了其他发布内容,其中Devel模块可以搞乱输出,但是我在用户注销时看到了以上内容(因此,匿名用户禁用了Devel)。

Any idea what could be going wrong? 任何想法可能出什么问题吗? My view is set to be an "HTML List", grouped by "Resource Type". 我的视图设置为“ HTML列表”,按“资源类型”分组。

Not 100% sure, given that I do not have your setup to make tests, but it looks like you are experiencing this issue . 鉴于我没有您进行测试的设置,所以不是100%肯定,但是您似乎遇到了此问题 On comment #16 Merlin of Chaos (the author of views) provides a patch that subsequent comments seem to confirm as "working". 在注释16中,混沌的梅林(观点的作者)提供了一个补丁,后续的注释似乎可以确认是“有效的”。

If that is not the case, a workaround could be for you to sort nodes instead of grouping them. 如果不是这种情况,则可以采用一种解决方法来对节点排序而不是对节点进行分组。 You could add the grouping header by passing to the template also the node type value: you then would add the header with the type of content by comparing with the previous one. 您可以通过将节点类型值也传递到模板来添加分组头:然后,通过与前一个进行比较,将头添加内容类型。 In pseudo-code: 用伪代码:

$type_in_use = 'xxx'
if $type_of_next_node != $type_in_use then
    $type_in_use = $type_of_next_node
    print_header($type_in_use)

Just an inelegant workaround, but should work! 只是一个微不足道的解决方法,但应该可以!

HTH 高温超导

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

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